ivanshamaev/de-agent-skills/docker-data-envs

Claude Code and agent skill by ivanshamaev/de-agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Docker for data engineering environments — multi-stage Dockerfiles for dbt/Spark/Airflow images, BuildKit layer caching (--mount=type=cache), private registries (ghcr.io/Harbor), docker buildx multi-platform builds, Docker Compose local data stacks (Spark+Airflow+Kafka+MinIO+Postgres), BuildKit secrets for private PyPI, security hardening (non-root user, slim base images, read-only FS), CI/CD with GitHub Actions build-push-action

Install

npx vskill@latest install ivanshamaev/de-agent-skills/docker-data-envs

SKILL.md

The same SKILL.md was published earlier as ivanshamaev/de-agent-skills/docker-data-envs.

Docker for Data Environments

When to Use

Load this skill when the user needs to:

  • Write or review Dockerfiles for data tools (dbt, Spark, Airflow, Flink, Trino, etc.)
  • Optimize Docker layer caching for faster CI/CD builds
  • Push/pull images to private registries (ghcr.io, Harbor) with proper tagging
  • Build multi-platform images with docker buildx for amd64/arm64
  • Stand up a local data stack with Docker Compose (Spark, Airflow, Kafka, MinIO, Postgres)
  • Securely pass private PyPI tokens or other secrets at build time with BuildKit
  • Harden container images: non-root user, minimal base, read-only filesystem, .dockerignore
  • Wire up GitHub Actions CI/CD pipelines that build and push data tool images

Multi-Stage Dockerfiles for Data Tools

dbt Image

Build: Python base, install adapters from requirements.txt, copy project last.

dockerfile
# syntax=docker/dockerfile:1.7
ARG PYTHON_VERSION=3.11
ARG DBT_CORE_VERSION=1.8.*
ARG DBT_TRINO_VERSION=1.8.*
# ── build stage ──────────────────────────────────────────────────────────────
FROM python:${PYTHON_VERSION}-slim AS builder
WORKDIR /build
# Copy dependency manifest first — this layer is cached until requirements change
COPY requirements.txt .
# BuildKit cache mount: pip cache survives across builds on the same host
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip \
&& pip install \
dbt-core==${DBT_CORE_VERSION} \
dbt-trino==${DBT_TRINO_VERSION} \
dbt-postgres \
-r requirements.txt \
--no-cache-dir \
--prefix=/install
# ── runtime stage ─────────────────────────────────────────────────────────────
FROM python:${PYTHON_VERSION}-slim AS runtime
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/install/bin:$PATH" \
PYTHONPATH="/install/lib/python3.11/site-packages"
# Non-root user
RUN groupadd --gid 1001 dbt \
&& useradd --uid 1001 --gid dbt --shell /bin/bash --create-home dbt
WORKDIR /dbt
# Copy installed packages from builder
COPY --from=builder /install /install
# Copy project files last (most frequently changed)
COPY --chown=dbt:dbt . .
USER dbt
ENTRYPOINT ["dbt"]
CMD ["--version"]

requirements.txt example:

dbt-core==1.8.*
dbt-trino==1.8.*
dbt-utils==1.3.*
Spark Image

Build: OpenJDK slim, add JARs, install PySpark + Python dependencies.

dockerfile
# syntax=docker/dockerfile:1.7
ARG JAVA_VERSION=17
ARG SPARK_VERSION=3.5.3
ARG HADOOP_VERSION=3
ARG SCALA_VERSION=2.12
# ── spark download stage ──────────────────────────────────────────────────────
FROM eclipse-temurin:${JAVA_VERSION}-jre-jammy AS spark-download
ARG SPARK_VERSION
ARG HADOOP_VERSION
WORKDIR /opt
RUN apt-get update && apt-get install -y --no-install-recommends curl tar \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL \
"https://downloads.apache.org/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION}.tgz" \
| tar -xzf - \
&& mv spark-${SPARK_VERSION}-bin-hadoop${HADOOP_VERSION} spark
# ── extra JARs stage ──────────────────────────────────────────────────────────
FROM spark-download AS jars
ARG SCALA_VERSION
# Download connector JARs into the Spark jars directory
RUN curl -fsSL -o /opt/spark/jars/iceberg-spark-runtime-3.5_${SCALA_VERSION}-1.6.1.jar \
"https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-spark-runtime-3.5_${SCALA_VERSION}/1.6.1/iceberg-spark-runtime-3.5_${SCALA_VERSION}-1.6.1.jar" \
&& curl -fsSL -o /opt/spark/jars/aws-java-sdk-bundle-1.12.262.jar \
"https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-bundle/1.12.262/aws-java-sdk-bundle-1.12.262.jar"
# ── python deps stage ─────────────────────────────────────────────────────────
FROM python:3.11-slim AS pydeps
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
pip install pyspark==3.5.3 delta-spark==3.2.0 -r requirements.txt \
--no-cache-dir \
--prefix=/pyinstall
# ── runtime stage ─────────────────────────────────────────────────────────────
FROM eclipse-temurin:${JAVA_VERSION}-jre-jammy AS runtime
ENV SPARK_HOME=/opt/spark \
PATH="/opt/spark/bin:/opt/spark/sbin:$PATH" \
PYSPARK_PYTHON=python3 \
PYTHONPATH="/pyinstall/lib/python3.11/site-packages" \
PYTHONUNBUFFERED=1
# Install Python runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 python3-distutils \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 1001 spark \
&& useradd --uid 1001 --gid spark --shell /bin/bash --create-home spark
COPY --from=jars /opt/spark /opt/spark
COPY --from=pydeps /pyinstall /pyinstall
WORKDIR /opt/spark
USER spark
ENTRYPOINT ["/opt/spark/bin/spark-submit"]
Airflow Custom Image

Extend the official image with custom providers and packages.

dockerfile
# syntax=docker/dockerfile:1.7
ARG AIRFLOW_VERSION=2.10.4
ARG PYTHON_VERSION=3.11
FROM apache/airflow:${AIRFLOW_VERSION}-python${PYTHON_VERSION} AS base
# Switch to root only for system-level packages
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
USER airflow
# Copy constraints/requirements before project files
COPY --chown=airflow:root requirements-airflow.txt .
# Use pip cache mount + official constraints
ARG CONSTRAINTS_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
RUN --mount=type=cache,target=/home/airflow/.cache/pip,uid=50000,gid=0 \
pip install --no-cache-dir \
-r requirements-airflow.txt \
--constraint "${CONSTRAINTS_URL}"
# Copy DAGs and plugins last
COPY --chown=airflow:root dags/ /opt/airflow/dags/
COPY --chown=airflow:root plugins/ /opt/airflow/plugins/

requirements-airflow.txt example:

apache-airflow-providers-trino==5.7.3
apache-airflow-providers-amazon==8.26.0
apache-airflow-providers-databricks==6.8.0
dbt-core==1.8.*
dbt-trino==1.8.*

Layer Caching Strategy

Rule: order instructions from least-changed to most-changed.

FROM ← changes only when base image bumps (rare)
ARG / ENV (build-time only) ← rarely changes
RUN apt-get install ← changes when system deps change
COPY requirements*.txt . ← changes when adding/removing packages
RUN pip install ← invalidated only when requirements change
COPY . . ← changes on every source code edit
RUN <compile/test step>

Use --mount=type=cache so pip and apt caches survive cache misses:

dockerfile
# apt cache (persisted at /var/cache/apt)
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends gcc
# pip cache
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt

Separate stable and volatile requirements files:

requirements-base.txt # numpy, pandas, pyarrow — change rarely
requirements-app.txt # project-specific packages — change often
dockerfile
COPY requirements-base.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements-base.txt
COPY requirements-app.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements-app.txt
COPY . .

Private Registry: ghcr.io and Harbor

Image Tagging Strategy

Use a combination of semantic version and git SHA for full traceability:

ghcr.io/org/spark-etl:3.5.3-abc1234 # semver + short SHA (immutable)
ghcr.io/org/spark-etl:3.5.3 # semver alias (updated on release)
ghcr.io/org/spark-etl:latest # mutable pointer (dev use only)
harbor.internal.corp/data/dbt:1.8.2-abc1234
Push/Pull — ghcr.io
bash
# Authenticate
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
# Build with multi-platform
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/org/dbt-trino:1.8.2-$(git rev-parse --short HEAD) \
--tag ghcr.io/org/dbt-trino:1.8.2 \
--push \
.
# Pull
docker pull ghcr.io/org/dbt-trino:1.8.2-abc1234
Push/Pull — Harbor (self-hosted)
bash
# Authenticate
docker login harbor.internal.corp \
--username "${HARBOR_USER}" \
--password "${HARBOR_PASSWORD}"
# Tag and push
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag harbor.internal.corp/data/spark-etl:3.5.3-$(git rev-parse --short HEAD) \
--cache-from type=registry,ref=harbor.internal.corp/data/spark-etl:buildcache \
--cache-to type=registry,ref=harbor.internal.corp/data/spark-etl:buildcache,mode=max \
--push \
.
docker buildx Multi-Platform Setup
bash
# Create and use a multi-platform builder (run once per CI runner or machine)
docker buildx create \
--name multiarch-builder \
--driver docker-container \
--use
docker buildx inspect --bootstrap
# Build for both architectures, push directly to registry
docker buildx build \
--platform linux/amd64,linux/arm64 \
--file Dockerfile.spark \
--tag ghcr.io/org/spark-etl:${VERSION}-${GIT_SHA} \
--tag ghcr.io/org/spark-etl:${VERSION} \
--push \
.

Docker Compose for Local Data Stacks

Complete compose.yaml for a local Spark + Airflow + Postgres + MinIO + Kafka + Schema Registry stack:

yaml
# compose.yaml — local data engineering stack
# Usage: docker compose up -d
# Requires: Docker Compose v2.20+
x-airflow-common: &airflow-common
image: ${AIRFLOW_IMAGE:-apache/airflow:2.10.4-python3.11}
environment: &airflow-env
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
AIRFLOW__CORE__FERNET_KEY: "${FERNET_KEY:?FERNET_KEY env var required}"
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: "true"
AIRFLOW__CORE__LOAD_EXAMPLES: "false"
AIRFLOW__WEBSERVER__SECRET_KEY: "${WEBSERVER_SECRET_KEY:?required}"
# S3-compatible storage (MinIO)
AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin
AWS_DEFAULT_REGION: us-east-1
AIRFLOW_CONN_MINIO_DEFAULT: >-
aws://minioadmin:minioadmin@?endpoint_url=http%3A%2F%2Fminio%3A9000&region_name=us-east-1
volumes:
- ./dags:/opt/airflow/dags
- ./plugins:/opt/airflow/plugins
- airflow-logs:/opt/airflow/logs
depends_on:
postgres:
condition: service_healthy
networks:
- data-net
services:
# ── Postgres (Airflow metadata + general use) ──────────────────────────────
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-db:/docker-entrypoint-initdb.d # extra DBs for dbt etc.
healthcheck:
test: ["CMD-SHELL", "pg_isready -U airflow"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- data-net
# ── Airflow ────────────────────────────────────────────────────────────────
airflow-init:
<<: *airflow-common
command: >
bash -c "
airflow db migrate &&
airflow users create
--username admin --password admin
--firstname Admin --lastname Admin
--role Admin --email admin@example.com
"
restart: "no"
airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- "8080:8080"
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
restart: unless-stopped

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ivanshamaev/de-agent-skills/docker-data-envs/badge)](https://verified-skill.com/skills/ivanshamaev/de-agent-skills/docker-data-envs)

Something wrong with this skill or its page? Tell us.