{"id":51383728,"url":"https://github.com/koniz-dev/docker-cookbook","last_synced_at":"2026-07-03T18:11:35.559Z","repository":{"id":330925382,"uuid":"1124454830","full_name":"koniz-dev/docker-cookbook","owner":"koniz-dev","description":"A comprehensive collection of production-grade Dockerfile best practices, optimizations, and security patterns for Java, Python, Node.js, Go, and React.","archived":false,"fork":false,"pushed_at":"2026-05-25T17:10:22.000Z","size":257,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T18:31:01.570Z","etag":null,"topics":["best-practices","devops","distroless","docker","dockerfile","go","golang","java","node","nodejs","optimization","python","react","security"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koniz-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T03:49:11.000Z","updated_at":"2026-05-25T17:10:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/koniz-dev/docker-cookbook","commit_stats":null,"previous_names":["koniz-dev/docker-cookbook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/koniz-dev/docker-cookbook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koniz-dev%2Fdocker-cookbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koniz-dev%2Fdocker-cookbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koniz-dev%2Fdocker-cookbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koniz-dev%2Fdocker-cookbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koniz-dev","download_url":"https://codeload.github.com/koniz-dev/docker-cookbook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koniz-dev%2Fdocker-cookbook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35096193,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-practices","devops","distroless","docker","dockerfile","go","golang","java","node","nodejs","optimization","python","react","security"],"created_at":"2026-07-03T18:11:34.952Z","updated_at":"2026-07-03T18:11:35.549Z","avatar_url":"https://github.com/koniz-dev.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐳 Docker Cookbook\n\n\u003e **A collection of production-grade Dockerfile best practices, optimization patterns, and advanced techniques.**\n\nThis project provides comprehensive guides, ranging from fundamentals to advanced (and extreme) optimization techniques, helping you build Docker images that are:\n- 📉 **Smallest** (Size optimization)\n- 🚀 **Fastest Startup** (Startup optimization)\n- 🛡️ **Most Secure** (Security hardening)\n- ⚡ **Most Efficient** (Build caching \u0026 CI/CD)\n\n---\n\n## 📂 Project Structure\n\nThe project is organized into modules based on popular languages/frameworks:\n\n### 1. 📘 [COOKBOOK.md](./COOKBOOK.md) (Core Guide)\nThe foundational guide applicable to all stacks:\n- **Fundamentals**: Containers vs VMs, Layers, OCI standards.\n- **Size Optimization**: Multi-stage builds, UPX, Brotli.\n- **Security**: Non-root users, distroless images, vulnerability scanning.\n- **BuildKit**: Cache mounts, secrets, SSH agents.\n- **CI/CD \u0026 Compose**: Standard patterns for DevOps.\n\n### 2. ☕ [Java / Spring Boot](./java/README.md)\nOptimized for the Java ecosystem:\n- **Zero-waste**: Custom JRE with `jlink` (~40MB JRE).\n- **Fast Startup**: JVM Tuning, CDS, Spring Boot Layertools.\n- **Security**: Distroless images, auto-dependency updates.\n- **Native**: GraalVM Native Image compilation.\n\n### 3. 🐍 [Python / FastAPI](./python/README.md)\nOptimized for Python backends:\n- **Performance**: `uv` package manager (10-100x faster than pip), `PYTHONOPTIMIZE`.\n- **Compatibility**: Solving `glibc` vs `musl` (Alpine) issues.\n- **Security**: Multi-arch Distroless, CVE auto-patching.\n- **Structure**: Virtual environment patterns.\n\n### 4. 🟩 [Node.js / Express](./node/README.md)\nOptimized for Node.js Backends/APIs:\n- **Stability**: `tini` for proper signal handling (PID 1).\n- **Security**: non-root user enforcement, distroless options.\n- **Efficiency**: `pnpm deploy` for ultimate dependency pruning.\n- **Production**: Multi-stage builds with minimal final image.\n\n### 5. 🐹 [Golang](./go/README.md)\nOptimized for Go Applications:\n- **Static**: `CGO_ENABLED=0` pure Go builds.\n- **Extreme**: `FROM scratch` + UPX compression (~2-5MB final image).\n- **Self-contained**: Inject SSL certs and user data into scratch.\n- **Security**: Zero-OS images for maximum hardening.\n\n### 6. ⚛️ [React / Vite](./react/README.md)\nOptimized for Frontend SPAs:\n- **Extreme Size**: Scratch image with statically compiled Nginx (~5MB).\n- **Performance**: Pre-compression (Gzip), Nginx caching strategy.\n- **Routing**: SPA fallback patterns.\n\n### 7. 🦀 [Rust / Axum](./rust/README.md)\nOptimized for Rust services:\n- **cargo-chef**: cached dependency builds.\n- **Static musl**: portable single binary.\n- **Distroless static**: ~9 MB final image.\n\n### 8. 🥟 [Bun](./bun/README.md)\nOptimized for Bun runtimes:\n- **`bun install`**: 5-20× faster than npm.\n- **`--compile`**: standalone executable for distroless deploys.\n\n### 9. 🟣 [.NET / ASP.NET Core](./dotnet/README.md)\nOptimized for .NET 9 services:\n- **Chiseled Ubuntu**: distroless-style runtime, glibc-based.\n- **Non-root by default** (UID 1654, `app` user).\n- **`CreateSlimBuilder`**: trim-friendly minimal API host.\n\n---\n\n## 🚀 Quick Start\n\n### Check out Examples\n\nEach module contains ready-to-run `Dockerfile` examples:\n\n```bash\n# All variants in one shot via the Makefile\nmake build       # build every cookbook-* image\nmake sizes       # print a Markdown table of real measured sizes\nmake sizes.md    # write SIZES.md\n./scripts/bench.sh   # cold start + RSS + throughput → BENCHMARKS.md\n\n# Or build individually\ndocker build -t java-app ./java\ndocker build -f java/Dockerfile.distroless -t java-secure ./java\ndocker build -f go/Dockerfile.scratch -t go-extreme ./go\n# ...etc\n```\n\n\u003e **Sample apps** are included in each language folder (a minimal HTTP server\n\u003e with `/` and `/health`). So `docker build ./go` works end-to-end against the\n\u003e sample; swap in your own app code by replacing the sources.\n\nSee [`SIZES.md`](./SIZES.md) and [`BENCHMARKS.md`](./BENCHMARKS.md) for live measurements, and [`docs/distroless-debugging.md`](./docs/distroless-debugging.md) for surviving when something breaks inside a shell-less image.\n\n### Copy and Apply\n\n1.  Navigate to the directory matching your stack.\n2.  Read the `README.md` to understand the concepts.\n3.  Copy the sample `Dockerfile`.\n4.  Adjust filenames, ports, and build commands to fit your project.\n\n---\n\n## 💡 Philosophy\n\n1.  **Defaults to Secure**: Always run as non-root, read-only filesystem where possible.\n2.  **Every Byte Counts**: No waste, no redundant caches in production images.\n3.  **Build Once, Run Anywhere**: Leverage multi-platform builds.\n4.  **Fail Fast**: Proper healthchecks and signal handling.\n\n---\n\n## 🤝 Contributing\n\nAll contributions (PRs, Issues) are welcome! Please open an issue if you'd like to request a guide for another framework (Golang, Rust, Node.js API, etc.).\n\n---\n\n*© 2025 Koniz Dev. Open source under MIT License.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoniz-dev%2Fdocker-cookbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoniz-dev%2Fdocker-cookbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoniz-dev%2Fdocker-cookbook/lists"}