PostgreSQL statt SQLite: eigener DB-Container in Compose
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
- POSTGRES_USER=webcad
|
||||
- POSTGRES_PASSWORD=webcad
|
||||
- POSTGRES_DB=webcad
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U webcad"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
|
||||
backend:
|
||||
image: node:22-alpine
|
||||
working_dir: /app
|
||||
@@ -8,6 +23,11 @@ services:
|
||||
- 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:
|
||||
@@ -20,6 +40,9 @@ services:
|
||||
rm -rf /tmp/repo
|
||||
npm ci --only=production
|
||||
node server.js
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:5000/api/health',r=>{process.exit(r.statusCode===200?0:1)})"]
|
||||
interval: 15s
|
||||
@@ -43,7 +66,7 @@ services:
|
||||
rm -rf /tmp/repo
|
||||
npm ci
|
||||
npx vite build --mode production
|
||||
npx serve -s dist -l 80
|
||||
npx vite preview --host 0.0.0.0 --port 80
|
||||
depends_on:
|
||||
- backend
|
||||
healthcheck:
|
||||
@@ -51,5 +74,8 @@ services:
|
||||
interval: 15s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
start_period: 90s
|
||||
start_period: 120s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
|
||||
Reference in New Issue
Block a user