Multi-Stage Production Dockerfile & GitHub Actions CI/CD Pipeline
Write minimal, secure multi-stage Dockerfiles and automated GitHub Actions workflows with linting, testing, and cloud deployment.
System Directive • Copy and Paste Below
Act as a senior Cloud Infrastructure and DevOps Automation engineer. Create a minimal, secure, production-grade multi-stage Dockerfile and a complete GitHub Actions CI/CD pipeline for our application. ### APPLICATION SPECIFICATIONS: - Tech Stack & Runtime: [RUNTIME_E_G_NODEJS_20_NEXTJS_PYTHON_3_12_GOLANG] - Package Manager: [PACKAGE_MANAGER_E_G_PNPM_NPM_UV_POETRY] - Build Artifact Type (Static export, standalone server, binary): [BUILD_TYPE] - Target Deployment Cloud (AWS ECS, DigitalOcean App Platform, Fly.io, Self-hosted VPS): [DEPLOYMENT_TARGET] ### DELIVERABLES: 1. **Optimized Multi-Stage `Dockerfile`**: - Stage 1 (`base` / `deps`): Layer caching package manifests for lightning-fast rebuilds. - Stage 2 (`builder`): Compiling application, stripping devDependencies. - Stage 3 (`runner`): Minimal distroless or alpine base image, executing as a non-root user (`USER node` or `USER appuser`). - Built-in `HEALTHCHECK` directive. 2. **`.dockerignore` File**: - Comprehensive exclusion list preventing node_modules, .git, secrets, and test files from bloating the build context. 3. **GitHub Actions CI/CD Workflow (`.github/workflows/deploy.yml`)**: - Triggers: On pull request (lint + unit tests) and on merge to `main` (build + push + deploy). - Caching: Utilizing Docker Buildx and GitHub Actions cache for layer reuse. - Security Scanning: Trivy or Snyk vulnerability scan stage before deployment. - Deploy Step: Automated zero-downtime rolling restart command on [DEPLOYMENT_TARGET].
Customization & Placeholders
Specify your runtime and package manager. The multi-stage build drops image size by up to 85% and runs as non-root for security.
Example Input Values
Runtime: Node.js 20 with Next.js App Router (standalone output), Package Manager: pnpm, Target: AWS ECS / Docker container.
Expected Output Structure
Complete multi-stage Dockerfile (under 120MB final image), .dockerignore, and GitHub Actions workflow with caching.
Cloud Infrastructure & CI/CD by Qubenix
Qubenix automates cloud infrastructure, continuous deployment pipelines, and zero-downtime server architectures.
More Prompts in Coding & Development
React & TypeScript Clean Component Architecture & State Management
Architect clean, maintainable React 19 / TypeScript components using compound patterns, custom hooks, and zero re-render bloat.
PostgreSQL / MySQL Query Optimization, Indexing & EXPLAIN ANALYZE
Diagnose slow database queries, optimize table schemas, and design composite B-Tree/GIN indexes to drop execution time by 90%+.
Enterprise REST & GraphQL API Schema Designer with OpenAPI Specs
Design clean, pragmatic RESTful endpoints or GraphQL schemas adhering to OpenAPI 3.1 standards, pagination, and status codes.