wget in node:22-alpine can't connect to localhost:3000 — use node's built-in fetch instead, which works correctly.
32 lines
730 B
YAML
32 lines
730 B
YAML
services:
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
expose:
|
|
- "8080"
|
|
environment:
|
|
- PORT=8080
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 5s
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
expose:
|
|
- "3000"
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
environment:
|
|
- API_URL=http://backend:8080
|
|
healthcheck:
|
|
test: ["CMD", "node", "-e", "fetch('http://localhost:3000').then(r=>{if(!r.ok)throw r.status;process.exit(0)}).catch(()=>process.exit(1))"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|