This skill should be used when the user asks to "build multiple Dockerfiles", "compile varios dockerfiles", "multi-container build", "multiple Docker images in GitLab", "parallel Docker builds", "monorepo Docker builds", "build frontend backend worker containers", or needs to build multiple Docker images from different Dockerfiles in a single GitLab project using To-Be-Continuous Docker template.
/plugin marketplace add rafaelcalleja/claude-market-place/plugin install gitlab-tbc@claude-market-placeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Knowledge base for building multiple Docker images from different Dockerfiles in a single GitLab project using the To-Be-Continuous Docker template.
When a project contains multiple Dockerfiles (e.g., frontend, backend, worker), the TBC Docker template supports multi-instantiation to build all images in parallel using Kaniko, Buildah, or Docker-in-Docker.
The recommended approach is to use GitLab CI's parallel:matrix feature to instantiate the Docker template multiple times with different configurations.
include:
- component: $CI_SERVER_FQDN/to-be-continuous/docker/gitlab-ci-docker@6
inputs:
build-tool: kaniko
# Multi-instantiate the Docker template
.docker-base:
parallel:
matrix:
# Configuration for each Dockerfile
- DOCKER_FILE: path/to/Dockerfile1
DOCKER_CONTEXT_PATH: path/to/context1
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/service1:$CI_COMMIT_REF_SLUG
DOCKER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/service1:$CI_COMMIT_REF_NAME
- DOCKER_FILE: path/to/Dockerfile2
DOCKER_CONTEXT_PATH: path/to/context2
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/service2:$CI_COMMIT_REF_SLUG
DOCKER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/service2:$CI_COMMIT_REF_NAME
For each matrix entry, configure:
| Variable | Description | Example |
|---|---|---|
DOCKER_FILE | Path to Dockerfile | frontend/Dockerfile |
DOCKER_CONTEXT_PATH | Build context directory | frontend |
DOCKER_SNAPSHOT_IMAGE | Snapshot image name/tag | $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_SLUG |
DOCKER_RELEASE_IMAGE | Release image name/tag | $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_NAME |
| Variable | Description | Example |
|---|---|---|
DOCKER_BUILD_ARGS | Build arguments | --build-arg NODE_ENV=production |
DOCKER_METADATA | Custom labels | --label version=1.0 |
DOCKER_BUILD_CACHE_DISABLED | Disable cache | true |
include:
- component: $CI_SERVER_FQDN/to-be-continuous/docker/gitlab-ci-docker@6
inputs:
build-tool: kaniko
trivy-disabled: false
hadolint-disabled: false
sbom-disabled: false
.docker-base:
parallel:
matrix:
# Frontend service
- DOCKER_FILE: frontend/Dockerfile
DOCKER_CONTEXT_PATH: frontend
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_SLUG
DOCKER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_NAME
DOCKER_BUILD_ARGS: "--build-arg NODE_ENV=production --build-arg API_URL=$API_URL"
# Backend API service
- DOCKER_FILE: backend/Dockerfile
DOCKER_CONTEXT_PATH: backend
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_SLUG
DOCKER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_NAME
DOCKER_BUILD_ARGS: "--build-arg DATABASE_URL=$DATABASE_URL"
# Worker service
- DOCKER_FILE: worker/Dockerfile
DOCKER_CONTEXT_PATH: worker
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/worker:$CI_COMMIT_REF_SLUG
DOCKER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/worker:$CI_COMMIT_REF_NAME
DOCKER_BUILD_ARGS: "--build-arg QUEUE_URL=$QUEUE_URL"
project/
├── .gitlab-ci.yml # Configuration with parallel:matrix
├── frontend/
│ ├── Dockerfile
│ ├── package.json
│ └── src/
├── backend/
│ ├── Dockerfile
│ ├── requirements.txt
│ └── app/
└── worker/
├── Dockerfile
└── tasks/
When using parallel:matrix, all TBC Docker jobs are multiplied for each matrix entry:
docker-hadolint (Dockerfile linting)docker-kaniko-build (or buildah/dind)docker-trivy (security scanning)docker-sbom (bill of materials)docker-healthcheck (health verification)docker-publish (release publishing)All builds run in parallel if GitLab runners are available, significantly reducing total pipeline time.
Each image has its own cache location:
${DOCKER_SNAPSHOT_IMAGE%:*}/cache$CI_PROJECT_DIR/.cacheEach build generates separate dotenv artifacts:
docker.env with variables:
docker_imagedocker_image_digestdocker_repositorydocker_tagdocker_digestFor cases requiring more control, define separate jobs:
include:
- component: $CI_SERVER_FQDN/to-be-continuous/docker/gitlab-ci-docker@6
# Disable default jobs
docker-kaniko-build:
rules:
- when: never
# Frontend build
docker-kaniko-build:frontend:
extends: .docker-kaniko-base
stage: package-build
variables:
DOCKER_FILE: frontend/Dockerfile
DOCKER_CONTEXT_PATH: frontend
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_SLUG
script:
- run_build_kaniko "$DOCKER_SNAPSHOT_IMAGE" --digest-file .img-digest-frontend.txt
# Backend build
docker-kaniko-build:backend:
extends: .docker-kaniko-base
stage: package-build
variables:
DOCKER_FILE: backend/Dockerfile
DOCKER_CONTEXT_PATH: backend
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_SLUG
script:
- run_build_kaniko "$DOCKER_SNAPSHOT_IMAGE" --digest-file .img-digest-backend.txt
All three build tools support multi-instantiation:
| Tool | Performance | Use Case |
|---|---|---|
| kaniko | Fast, optimized cache | Recommended default |
| buildah | Rootless, secure | Security-focused |
| dind | Full Docker API | Complex requirements |
With parallel:matrix, each image gets:
Disable per-build if needed:
.docker-base:
parallel:
matrix:
- DOCKER_FILE: frontend/Dockerfile
DOCKER_TRIVY_DISABLED: "true" # Skip Trivy for this image
- DOCKER_FILE: backend/Dockerfile
DOCKER_HADOLINT_DISABLED: "true" # Skip Hadolint for this image
For images sharing base layers or dependencies:
.docker-base:
parallel:
matrix:
# Base image (built first)
- DOCKER_FILE: base/Dockerfile
DOCKER_CONTEXT_PATH: base
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/base:$CI_COMMIT_REF_SLUG
DOCKER_BUILD_ARGS: "--cache-from $CI_REGISTRY_IMAGE/base:latest"
# Derived images (use base as cache)
- DOCKER_FILE: frontend/Dockerfile
DOCKER_CONTEXT_PATH: frontend
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_SLUG
DOCKER_BUILD_ARGS: "--cache-from $CI_REGISTRY_IMAGE/base:$CI_COMMIT_REF_SLUG"
Configure per-image publishing:
.docker-base:
parallel:
matrix:
# Auto-publish frontend
- DOCKER_FILE: frontend/Dockerfile
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_SLUG
DOCKER_PROD_PUBLISH_STRATEGY: auto
# Manual publish backend
- DOCKER_FILE: backend/Dockerfile
DOCKER_SNAPSHOT_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_SLUG
DOCKER_PROD_PUBLISH_STRATEGY: manual
The parallel:matrix syntax requires variables, not component inputs:
# WRONG - component inputs don't work with matrix
.docker-base:
parallel:
matrix:
- inputs:
file: frontend/Dockerfile # NOT SUPPORTED
# CORRECT - use variables
.docker-base:
parallel:
matrix:
- DOCKER_FILE: frontend/Dockerfile # SUPPORTED
If DOCKER_CONTEXT_PATH is not set, it defaults to the Dockerfile directory:
# These are equivalent:
- DOCKER_FILE: frontend/Dockerfile
DOCKER_CONTEXT_PATH: frontend
- DOCKER_FILE: frontend/Dockerfile
# DOCKER_CONTEXT_PATH auto-detected as "frontend"
Matrix jobs run in parallel. For build dependencies:
# Option 1: Use needs with artifacts
docker-kaniko-build:
parallel:
matrix:
- DOCKER_FILE: base/Dockerfile
JOB_ORDER: "1"
- DOCKER_FILE: app/Dockerfile
JOB_ORDER: "2"
docker-kaniko-build:app:
needs:
- docker-kaniko-build: [base]
Each image should have unique cache locations:
.docker-base:
parallel:
matrix:
- DOCKER_FILE: service1/Dockerfile
KANIKO_SNAPSHOT_IMAGE_CACHE: $CI_REGISTRY_IMAGE/service1/cache
- DOCKER_FILE: service2/Dockerfile
KANIKO_SNAPSHOT_IMAGE_CACHE: $CI_REGISTRY_IMAGE/service2/cache
docs/to-be-continuous-knowledge/templates/docker/This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.