docker-infra-workflow

Automate Docker and Docker Compose infrastructure with multi-stage builds and healthchecks.

Updated Nov 26, 2025
One-click install
npx skills add https://github.com/guiledo/dotfiles --skill docker-infra-workflow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-infra-workflow
Source: https://github.com/guiledo/dotfiles/tree/main/opencode/.config/opencode/skills/docker-infra-workflow
Command: npx skills add https://github.com/guiledo/dotfiles --skill docker-infra-workflow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill ensures that application environments are reproducible, secure, and production-ready using Docker and modern containerization practices.

Core Features & Use Cases

  • Multi-stage builds are mandatory: Enforce separate builder and runner stages to keep production images lean.
  • Least Privilege (Never run as root): Always create non-root users and switch to them in the final image.
  • Layer Caching & Immutability: Copy dependency manifests first and install to leverage Docker's layer caching.

Core Rules for Docker Compose (Local Dev)

  • Persistence: Use named volumes for databases and brokers to avoid data loss on restarts.
  • Healthchecks & Dependency Ordering: Add healthchecks and use depends_on with condition: service_healthy.
  • Environment Variables: Do not hardcode secrets; use .env files or environment interpolation.

Workflow

  1. Analyze Stack: Determine language, framework, and required external services (DB, Cache).
  2. Draft Dockerfile: Create an optimized, multi-stage Dockerfile.
  3. Draft Compose: Create a docker-compose.yml for local development.
  4. Explain: Briefly explain to the user how to start the environment.

Quick Start

Set up a reproducible local environment for a sample app using a multi-stage Dockerfile and docker-compose.

Frequently Asked Questions about docker-infra-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a reproducible Docker environment for local development?

To create a reproducible local development environment, draft a docker-compose.yml using named volumes for persistence, healthchecks, and depends_on with condition: service_healthy. This ensures databases and brokers survive restarts and start in the correct order.

Why use multi-stage builds for containerized applications?

Multi-stage builds enforce separate builder and runner stages to keep production images lean. By copying only necessary artifacts to the final stage, you reduce image size and minimize the attack surface for better container security.

What is the best way to manage environment variables and secrets in Docker Compose?

The best way to manage environment variables in Docker Compose is using .env files or environment interpolation. You should never hardcode secrets directly in the docker-compose.yml file to maintain security across your CI/CD pipelines.

How do I optimize layer caching when building Docker images?

Optimize layer caching by copying dependency manifests first and running the installation step before copying the rest of the source code. This ensures Docker reuses the cached dependencies layer unless the manifests change.

Does Docker require running containers as root?

Docker does not require running containers as root. You should apply least privilege by creating a non-root user and switching to it in the final image, ensuring your production container runtime is secure.