Single container: Backend serves API + Frontend static files + SPA fallback

This commit is contained in:
Agent Zero
2026-05-25 17:03:06 +00:00
parent c7899ae4f6
commit 2c5fe4dae9
8 changed files with 554 additions and 31 deletions
-29
View File
@@ -22,14 +22,11 @@ services:
environment:
- NODE_ENV=production
- JWT_SECRET=cad-jwt-secret-prod-2026
- PORT=5000
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=webcad
- DB_PASSWORD=webcad
- DB_NAME=webcad
expose:
- "5000"
command:
- sh
- '-c'
@@ -51,31 +48,5 @@ services:
start_period: 40s
restart: unless-stopped
frontend:
image: node:22-alpine
working_dir: /app
expose:
- "80"
command:
- sh
- '-c'
- |
apk add --no-cache git
git clone --depth 1 https://forgejo.media-on.de/Leopoldadmin/web-cad.git /tmp/repo
cp -r /tmp/repo/frontend/* /app/
rm -rf /tmp/repo
npm ci
npx vite build --mode production
npx vite preview --host 0.0.0.0 --port 80
depends_on:
- backend
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:80/',r=>{process.exit(r.statusCode===200?0:1)})"]
interval: 15s
timeout: 5s
retries: 15
start_period: 120s
restart: unless-stopped
volumes:
pg_data: