feat: enhance Docker setup and deployment configuration

This commit is contained in:
Jose Selesan
2026-09-28 16:41:28 -03:00
parent 2370895710
commit f05fbf9e30
8 changed files with 279 additions and 1 deletions

62
docker-compose.yml Normal file
View File

@@ -0,0 +1,62 @@
# Deploy en Dokploy (o `docker compose up --build` en cualquier lado).
#
# El dominio público se expone una sola vez, en `web`: nginx sirve el bundle de
# Vite y hace de proxy de /api hacia el contenedor `api`. Eso deja la cookie de
# sesión first-party (no hace falta SameSite=None) y vuelve innecesario el
# preflight CORS. Si preferís subdominio aparte para la API, quitá el bloque
# `location /api/` de apps/web/nginx.conf y seteá VITE_API_URL al construir web.
x-backend-env: &backend-env
NODE_ENV: production
# Web y API comparten dominio público: mismo origen para cookies y CORS.
DATABASE_URL: ${DATABASE_URL:?definí DATABASE_URL (postgresql://user:pass@host:5432/gruperly?schema=public)}
BETTER_AUTH_URL: ${PUBLIC_URL:?definí PUBLIC_URL con la URL pública de la app}
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:?definí BETTER_AUTH_SECRET (openssl rand -base64 32)}
WEB_URL: ${PUBLIC_URL:?definí PUBLIC_URL con la URL pública de la app}
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID:-}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET:-}
EMAIL_PROVIDER: ${EMAIL_PROVIDER:-smtp}
EMAIL_SERVER_HOST: ${EMAIL_SERVER_HOST:-}
EMAIL_SERVER_PORT: ${EMAIL_SERVER_PORT:-587}
EMAIL_SERVER_USER: ${EMAIL_SERVER_USER:-}
EMAIL_SERVER_PASSWORD: ${EMAIL_SERVER_PASSWORD:-}
EMAIL_FROM: ${EMAIL_FROM:-Gruperly <no-reply@gruperly.com>}
services:
# Corre una vez por deploy: aplica prisma/migrations y sale con código 0.
# No reinicia nunca; si falla, `api` no arranca (ver depends_on de más abajo).
migrate:
build:
context: .
dockerfile: Dockerfile.backend
target: migrate
environment:
DATABASE_URL: ${DATABASE_URL:?definí DATABASE_URL (postgresql://user:pass@host:5432/gruperly?schema=public)}
restart: "no"
api:
build:
context: .
dockerfile: Dockerfile.backend
target: api
environment: *backend-env
restart: unless-stopped
depends_on:
migrate:
condition: service_completed_successfully
expose:
- "4000"
web:
build:
context: .
dockerfile: Dockerfile.web
target: web
args:
# Se hornea en el bundle. Vacío = mismo origen (proxy /api de nginx).
VITE_API_URL: ${VITE_API_URL:-}
restart: unless-stopped
depends_on:
- api
ports:
- "8080:80"