Skip to content

fix: harden Docker builds for Coolify production deployments#9

Merged
dherrero merged 2 commits into
mainfrom
feat/docker-production-fixes
Apr 28, 2026
Merged

fix: harden Docker builds for Coolify production deployments#9
dherrero merged 2 commits into
mainfrom
feat/docker-production-fixes

Conversation

@dherrero
Copy link
Copy Markdown
Owner

Summary

Applies all fixes discovered during the first real Coolify deployment of a project based on this starter. Every issue blocked the Docker build or prevented Traefik from routing traffic to the frontend.

  • Node 18 → 22-slim in both Dockerfiles — Angular 21 + NX 22 dropped Node 18 support
  • HUSKY=0 before npm install — the prepare lifecycle script fails in Docker because .git is excluded from the build context
  • NODE_OPTIONS=--max-old-space-size=3072 — prevents Angular OOM during production build
  • Backend runtime: node:22-slim (Debian) instead of Alpine — native modules (bcrypt, pdf2pic) compile for glibc and can't run on Alpine's musl libc
  • npm prune --omit=dev instead of npm install --omit=dev in dist — NX generatePackageJson: true copies the full workspace package-lock.json to dist, which conflicts with a fresh install; pruning the workspace node_modules and copying them avoids the conflict
  • nginx/default.conf placeholder fixed — replaced YOUR_BACK_DOMAIN_HERE with http://back:3200
  • .dockerignore added — excludes node_modules, dist, .git, .env from build context; removed .dockerignore from .gitignore so it is tracked
  • environment.prod.example.ts fixed — wrong variable name (environmentenv) and absolute URL replaced with relative /api/v1/
  • Front Dockerfile: env fallback — copies example file if environment.prod.ts is absent so the build works out of the box
  • compose.yaml: ports + network for front service — without a ports entry Coolify/Traefik has no port to proxy to for the domain

Test plan

  • docker compose build succeeds locally
  • docker compose up brings up all three services
  • Frontend is accessible and proxies API calls to backend via nginx
  • Coolify deployment succeeds end-to-end on a new project created from this starter

🤖 Generated with Claude Code

dherrero and others added 2 commits April 28, 2026 18:23
- Upgrade base images from node:18-slim to node:22-slim (Angular 21 + NX 22 require Node 20+)
- Add HUSKY=0 to prevent husky prepare script from failing in Docker (no .git in build context)
- Add NODE_OPTIONS max-old-space-size=3072 to prevent Angular OOM during build
- Fix back runtime image to use node:22-slim (Debian) instead of Alpine to support native modules (bcrypt, pdf2pic)
- Switch from npm install --omit=dev in dist to npm prune --omit=dev in workspace root, then copy node_modules — avoids NX lockfile conflict in dist
- Fix nginx/default.conf placeholder: replace YOUR_BACK_DOMAIN_HERE with http://back:3200
- Add .dockerignore to exclude node_modules, dist, .git, .env from Docker build context
- Add environment.prod.ts fallback in front Dockerfile (copies example if prod file absent)
- Fix environment.prod.example.ts: use correct 'env' export name and relative /api/v1/ path
- Remove .dockerignore from .gitignore so it is tracked by git

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without ports, Coolify/Traefik cannot route traffic to the frontend.
Also adds front to back-starter-network so nginx can proxy to back.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant