Skip to content

Fix Dockerfile with multi-stage build and frontend support - #36

Merged
antosubash merged 1 commit into
mainfrom
feature/recursing-clarke
Mar 30, 2026
Merged

antosubash merged 1 commit into
mainfrom
feature/recursing-clarke

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • Rewrites the Dockerfile with a proper 4-stage multi-stage build (base → restore → build → runtime) that includes Node.js 22 for React/Vite frontend builds, all 34+ .csproj files in the restore layer, Tailwind CSS CLI download, and a non-root runtime user
  • Improves docker-compose.yml with API health checks, PostgreSQL 17, environment variable for passwords, Database__Provider=PostgreSQL, and restart: unless-stopped
  • Expands .dockerignore to exclude node_modules/, bin/obj/, tests, docs, CLI, and AppHost — preventing huge Docker context transfers

Test plan

  • docker compose build succeeds (verified)
  • docker compose up starts both services, API connects to PostgreSQL (verified)
  • curl http://localhost:8080/health/live returns 200 after migrations complete
  • Browser at http://localhost:8080 serves React app with CSS

…-root user

The previous Dockerfile was broken: only 7 of 34+ .csproj files were copied
(restore failed), no Node.js for React/Vite frontend builds, and missing
global.json/Tailwind CLI. This rewrites all three Docker files:

Dockerfile:
- 4-stage build: base (SDK+Node.js) → restore → build → runtime
- All framework, module, and ServiceDefaults .csproj files in restore layer
- Node.js 22 LTS for Vite/React frontend builds
- Tailwind CSS CLI download for Linux (x64/arm64)
- npm ci + npm run build for all frontend workspaces
- Non-root appuser in runtime image
- ErrorOnDuplicatePublishOutputFiles for module package.json conflicts

docker-compose.yml:
- Health check on API service (/health/live)
- PostgreSQL 16 → 17
- Environment variable for passwords (POSTGRES_PASSWORD)
- Added Database__Provider=PostgreSQL
- Development environment for auto-migration
- restart: unless-stopped on both services

.dockerignore:
- Exclude node_modules, bin/obj, tests, docs, cli, AppHost
- Prevent huge Docker context transfers
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying simplemodule-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: a953a5f
Status: ✅  Deploy successful!
Preview URL: https://e4a4f3c5.simplemodule-website.pages.dev
Branch Preview URL: https://feature-recursing-clarke.simplemodule-website.pages.dev

View logs

@antosubash
antosubash merged commit 2c156bd into main Mar 30, 2026
3 of 4 checks passed
antosubash added a commit that referenced this pull request Mar 30, 2026
The Tenants module (#32) landed after the Dockerfile rewrite (#36),
so its .csproj files were missing from the restore stage causing
docker build to fail with MSB4025.
antosubash added a commit that referenced this pull request Mar 30, 2026
The Tenants module (#32) landed after the Dockerfile rewrite (#36),
so its .csproj files were missing from the restore stage causing
docker build to fail with MSB4025.
@antosubash
antosubash deleted the feature/recursing-clarke branch April 1, 2026 15:15
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