$npx -y skills add mjunaidca/mjs-agent-skills --skill containerize-appsContainerizes applications with impact-aware Dockerfiles and docker-compose configurations. This skill should be used when containerizing projects for Docker, creating Dockerfiles, docker-compose files, or preparing applications for Kubernetes deployment. It performs impact analy
| 1 | # Containerize Apps |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This skill containerizes applications with **impact analysis first**, ensuring Docker configs work correctly with authentication, networking, and environment configuration. It generates Dockerfiles, docker-compose files, and documents required changes. |
| 6 | |
| 7 | ## Workflow |
| 8 | |
| 9 | ``` |
| 10 | 1. Impact Analysis → Scan project for containerization requirements |
| 11 | 2. Blueprint Selection → Choose appropriate Dockerfile patterns |
| 12 | 3. Configuration Gen → Generate Dockerfiles + docker-compose |
| 13 | 4. Impact Documentation → Document required code/config changes |
| 14 | 5. Optional: Gordon → Validate with Docker AI (if available) |
| 15 | ``` |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ## Step 1: Impact Analysis (REQUIRED) |
| 20 | |
| 21 | Before generating ANY container configuration, invoke the impact-analyzer subagent: |
| 22 | |
| 23 | ``` |
| 24 | Use Task tool with: |
| 25 | subagent_type: "impact-analyzer" |
| 26 | prompt: | |
| 27 | Analyze this project for containerization requirements. |
| 28 | |
| 29 | Scan for: |
| 30 | 1. Environment variables (build-time vs runtime) |
| 31 | 2. Localhost/127.0.0.1 references that need Docker service names |
| 32 | 3. Auth/CORS configurations (Better Auth trustedOrigins, FastAPI CORS) |
| 33 | 4. Service dependencies and startup order |
| 34 | 5. Ports used by each service |
| 35 | |
| 36 | Return structured findings for containerization. |
| 37 | ``` |
| 38 | |
| 39 | **Wait for the analysis report before proceeding.** |
| 40 | |
| 41 | The report will identify: |
| 42 | - Environment variables needing configuration |
| 43 | - URLs that must change for container networking |
| 44 | - Auth configs requiring origin updates |
| 45 | - Service dependency graph |
| 46 | |
| 47 | --- |
| 48 | |
| 49 | ## Step 2: Blueprint Selection |
| 50 | |
| 51 | Based on project analysis, select appropriate blueprints from `assets/`: |
| 52 | |
| 53 | | Project Type | Blueprint | Key Considerations | |
| 54 | |--------------|-----------|-------------------| |
| 55 | | FastAPI/Python | `Dockerfile.fastapi` | uv, multi-stage, non-root | |
| 56 | | Next.js | `Dockerfile.nextjs` | standalone output, NEXT_PUBLIC_* | |
| 57 | | Python Service | `Dockerfile.python` | Generic Python app | |
| 58 | | MCP Server | `Dockerfile.mcp` | Based on Python service | |
| 59 | |
| 60 | --- |
| 61 | |
| 62 | ## Step 3: Generate Configurations |
| 63 | |
| 64 | ### 3.1 Dockerfiles |
| 65 | |
| 66 | For each service, generate Dockerfile using blueprint + impact analysis: |
| 67 | |
| 68 | **Customization points:** |
| 69 | ```dockerfile |
| 70 | # From impact analysis - replace these: |
| 71 | CMD ["uvicorn", "{{MODULE_PATH}}:app", ...] # Module path from project |
| 72 | EXPOSE {{PORT}} # Port from analysis |
| 73 | ENV {{ENV_VARS}} # Runtime env vars |
| 74 | ARG {{BUILD_ARGS}} # Build-time vars (NEXT_PUBLIC_*) |
| 75 | ``` |
| 76 | |
| 77 | ### 3.2 docker-compose.yml |
| 78 | |
| 79 | Generate compose file with proper networking: |
| 80 | |
| 81 | ```yaml |
| 82 | # Network topology from impact analysis |
| 83 | services: |
| 84 | web: |
| 85 | build: |
| 86 | context: ./web-dashboard |
| 87 | args: |
| 88 | # BROWSER: baked into JS bundle, runs on user's machine |
| 89 | - NEXT_PUBLIC_API_URL=http://localhost:8000 |
| 90 | - NEXT_PUBLIC_SSO_URL=http://localhost:3001 |
| 91 | environment: |
| 92 | - NODE_ENV=production |
| 93 | # SERVER: read at runtime, runs inside container |
| 94 | - SERVER_API_URL=http://api:8000 |
| 95 | - SERVER_SSO_URL=http://sso-platform:3001 |
| 96 | ports: |
| 97 | - "3000:3000" |
| 98 | depends_on: |
| 99 | api: |
| 100 | condition: service_healthy |
| 101 | |
| 102 | api: |
| 103 | build: |
| 104 | context: ./packages/api |
| 105 | environment: |
| 106 | - DATABASE_URL=${DATABASE_URL} # From .env (external Neon) |
| 107 | - FRONTEND_URL=http://web:3000 # Docker service name! |
| 108 | - CORS_ORIGINS=http://localhost:3000,http://web:3000 |
| 109 | ports: |
| 110 | - "8000:8000" |
| 111 | healthcheck: |
| 112 | test: ["CMD", "curl", "-f", "http://localhost:8000/health"] |
| 113 | interval: 30s |
| 114 | timeout: 10s |
| 115 | retries: 3 |
| 116 | start_period: 40s |
| 117 | |
| 118 | # Add other services based on analysis... |
| 119 | ``` |
| 120 | |
| 121 | ### 3.3 .env.docker Template |
| 122 | |
| 123 | Generate environment template for Docker: |
| 124 | |
| 125 | ```bash |
| 126 | # External services (keep actual values) |
| 127 | DATABASE_URL=postgresql://...@neon.tech/... |
| 128 | |
| 129 | # Docker networking (use service names) |
| 130 | API_URL=http://api:8000 |
| 131 | SSO_URL=http://sso:3001 |
| 132 | FRONTEND_URL=http://web:3000 |
| 133 | |
| 134 | # Secrets (in production, use Docker secrets or K8s secrets) |
| 135 | BETTER_AUTH_SECRET=your-secret-here |
| 136 | ``` |
| 137 | |
| 138 | --- |
| 139 | |
| 140 | ## Step 4: Document Required Changes |
| 141 | |
| 142 | Generate a `CONTAINERIZATION.md` documenting what needs to change in the codebase: |
| 143 | |
| 144 | ```markdown |
| 145 | # Containerization Impact Report |
| 146 | |
| 147 | ## Required Code Changes |
| 148 | |
| 149 | ### 1. Auth Configuration (sso-platform/src/lib/auth.ts) |
| 150 | Add Docker service names to trustedOrigins: |
| 151 | ```typescript |
| 152 | trustedOrigins: [ |
| 153 | "http://localhost:3000", |
| 154 | "http://localhost:8000", |
| 155 | "http://web:3000", // ADD: Docker frontend |
| 156 | "http://api:8000", // ADD: Docker back |