Generate a Production-Ready Docker Compose File

Generate a fully configured Docker Compose file with networking, volumes, health checks, and security best practices.

๐Ÿ“ The Prompt

Create a production-ready Docker Compose file for a [APPLICATION_TYPE] application with the following specifications: **Services Required:** 1. Application service running [FRAMEWORK/LANGUAGE] on port [APP_PORT] 2. Database service using [DATABASE_ENGINE] (e.g., PostgreSQL, MySQL, MongoDB) 3. Cache layer using [CACHE_SERVICE] (e.g., Redis, Memcached) 4. [ADDITIONAL_SERVICE] if applicable (e.g., Nginx reverse proxy, message queue) **Requirements:** - Use Docker Compose version 3.8 or later - Define a custom bridge network named [NETWORK_NAME] for inter-service communication - Configure named volumes for all persistent data (database storage, application uploads, etc.) - Include health checks for each service with appropriate intervals, timeouts, and retries - Set resource limits (CPU and memory) for each container suitable for a [ENVIRONMENT] environment (e.g., staging, production) - Use environment variables with a .env file pattern; provide a sample .env.example - Implement a proper restart policy for each service - Add depends_on with condition: service_healthy where applicable to enforce startup order - Include logging configuration with json-file driver and log rotation **Security Considerations:** - Do not hardcode secrets; use environment variable references - Run containers as non-root users where possible - Limit exposed ports to only what is necessary **Deliverables:** 1. The complete docker-compose.yml file with inline comments explaining key decisions 2. A sample .env.example file with placeholder values 3. A brief README section explaining how to start, stop, and troubleshoot the stack 4. Any required custom Dockerfile snippets if the base images need modification

๐Ÿ’ก Tips for Better Results

Specify your exact database version (e.g., PostgreSQL 16.2) rather than 'latest' to ensure reproducible builds. Describe your real application architecture in the APPLICATION_TYPE placeholder so the AI can tailor service dependencies accurately. Ask for a separate docker-compose.override.yml for local development settings to keep production config clean.

๐ŸŽฏ Use Cases

Backend developers and DevOps engineers who need to containerize a multi-service application quickly with production-grade defaults.

๐Ÿ”— Related Prompts

๐Ÿ’ป Coding beginner

Explain Code Like Im a Beginner

Get any code explained in plain English with line-by-line breakdowns, analogies, and learning suggestions.

๐Ÿ’ป Coding beginner

Debug My Code and Explain the Fix

Get your code debugged with clear explanations of what went wrong and why, plus the corrected version.

๐Ÿ’ป Coding intermediate

Write Unit Tests for My Code

Generate thorough unit tests covering edge cases, error handling, and both positive and negative scenarios.

๐Ÿ’ป Coding intermediate

Convert Code Between Languages

Convert code between any programming languages while maintaining idiomatic patterns and best practices.

๐Ÿ’ป Coding intermediate

Write a REST API Endpoint

Generate production-ready REST API endpoints with validation, error handling, and documentation.

๐Ÿ’ป Coding advanced

Create a GitHub Actions CI/CD Workflow for Automated Testing and Deployment

Generate a complete GitHub Actions CI/CD workflow with build, test, deploy, and notification jobs for your project.