-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.staging.yml
More file actions
136 lines (130 loc) · 4.75 KB
/
Copy pathdocker-compose.staging.yml
File metadata and controls
136 lines (130 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# docker-compose.staging.yml — stack staging de JobIT (Sprint 20.2, ADR-0012).
#
# USO LOCAL DE VALIDACIÓN. Diferencias con el VPS real (manual en fase 20.5):
# - Aquí API y Web publican puertos al host SOLO para el smoke local; en el
# VPS no se publicarían: Nginx Proxy Manager accede por la red interna.
# - PostgreSQL NUNCA publica puertos, en ningún entorno (decisión estructural).
# - Todos los valores sensibles de este archivo son DUMMIES de validación
# local ("change_me"); los valores reales de staging vivirán en el VPS,
# fuera del repo (plantillas env en fase 20.3).
#
# MIGRACIONES Y SEED: nunca automáticos (spec deploy-staging-readiness).
# La imagen runtime de la API no incluye la CLI de Prisma (solo dependencias
# de producción); migrar/seedear usa el stage `builder` del mismo Dockerfile,
# sin modificar ningún archivo:
#
# docker build --target builder -f apps/api/Dockerfile -t jobit-api:builder .
# docker run --rm --network jobit-staging \
# -e DATABASE_URL="postgresql://jobit_staging:jobit_staging_password_change_me@jobit-staging-db:5432/jobit_staging?schema=public" \
# jobit-api:builder pnpm --filter @jobit/api exec prisma migrate deploy
#
# # Seed opcional (14 ofertas mock, idempotente):
# docker run --rm --network jobit-staging \
# -e DATABASE_URL="postgresql://jobit_staging:jobit_staging_password_change_me@jobit-staging-db:5432/jobit_staging?schema=public" \
# jobit-api:builder pnpm --filter @jobit/api exec tsx prisma/seed.ts
name: jobit-staging
services:
jobit-staging-db:
image: postgres:16
container_name: jobit-staging-db
environment:
POSTGRES_DB: jobit_staging
POSTGRES_USER: jobit_staging
POSTGRES_PASSWORD: jobit_staging_password_change_me
volumes:
- jobit-staging-db-data:/var/lib/postgresql/data
networks:
- jobit-staging
# Sin `ports:`: la DB jamás se expone fuera de la red interna (ADR-0012).
healthcheck:
test: ["CMD-SHELL", "pg_isready -U jobit_staging -d jobit_staging"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
jobit-staging-api:
build:
context: .
dockerfile: apps/api/Dockerfile
image: jobit-api:staging-local
container_name: jobit-staging-api
depends_on:
jobit-staging-db:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 4000
DATABASE_URL: postgresql://jobit_staging:jobit_staging_password_change_me@jobit-staging-db:5432/jobit_staging?schema=public
JWT_ACCESS_SECRET: change-me-staging-jwt-access-secret
CORS_ORIGIN: http://localhost:3000
volumes:
# Único estado en disco de la API (avatares); incluido en backups (spec).
- jobit-staging-api-uploads:/repo/apps/api/uploads
networks:
- jobit-staging
# Publicado SOLO para el smoke local; en el VPS real este puerto no se
# publicaría (NPM llega a jobit-staging-api:4000 por la red interna).
ports:
- "4000:4000"
healthcheck:
# La imagen no trae curl; Node 20 tiene fetch global.
test: ["CMD", "node", "-e", "fetch('http://localhost:4000/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
jobit-staging-web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
# Se INLINEA en el build de Next: en el VPS real sería la URL pública
# de la API (https://api-jobit-staging.davlos.es) y exigiría rebuild.
NEXT_PUBLIC_API_BASE_URL: http://localhost:4000
image: jobit-web:staging-local
container_name: jobit-staging-web
depends_on:
jobit-staging-api:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 3000
HOSTNAME: 0.0.0.0
networks:
- jobit-staging
# Publicado SOLO para el smoke local; en el VPS real se conectaría según
# el manual de deploy (fase 20.5), sin puerto de host.
ports:
- "3000:3000"
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
networks:
jobit-staging:
name: jobit-staging
volumes:
jobit-staging-db-data:
name: jobit-staging-db-data
jobit-staging-api-uploads:
name: jobit-staging-api-uploads