fix: bearing maths
All checks were successful
Auto Tag on Merge to Main / auto-tag (push) Successful in 4s
CI - Lint and Build / lint-backend (push) Successful in 18s
CI - Lint and Build / lint-frontend (push) Successful in 13s
CI - Lint and Build / build-frontend (push) Successful in 15s
CI - Lint and Build / docker-build-test (push) Successful in 38s
All checks were successful
Auto Tag on Merge to Main / auto-tag (push) Successful in 4s
CI - Lint and Build / lint-backend (push) Successful in 18s
CI - Lint and Build / lint-frontend (push) Successful in 13s
CI - Lint and Build / build-frontend (push) Successful in 15s
CI - Lint and Build / docker-build-test (push) Successful in 38s
This commit is contained in:
@@ -1,17 +1,15 @@
|
||||
version: '3.8'
|
||||
|
||||
# Docker Compose para producción
|
||||
# Uso: docker compose -f docker-compose.prod.yml up -d --build
|
||||
# Uso: docker compose -f docker-compose.prod.yml up -d
|
||||
#
|
||||
# Requisitos previos:
|
||||
# 1. Configurar .env con valores de producción (ver .env.example)
|
||||
# 2. Configurar certificados SSL en ./nginx/ssl/ o usar certbot
|
||||
# 2. Login al registry: docker login tea.millaguie.net
|
||||
# 3. Configurar nginx/prod.conf con tu dominio
|
||||
|
||||
services:
|
||||
# Base de datos PostgreSQL con extensión PostGIS
|
||||
postgres:
|
||||
image: postgis/postgis:16-3.4-alpine # IMPORTANTE: usar versión 16 para compatibilidad
|
||||
image: postgis/postgis:16-3.4-alpine
|
||||
container_name: trenes-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
@@ -68,17 +66,42 @@ services:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- trenes-network
|
||||
profiles:
|
||||
- migration
|
||||
|
||||
# API Backend
|
||||
api:
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-api
|
||||
restart: unless-stopped
|
||||
command: ["node", "src/api/server.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
REDIS_URL: redis://redis:6379
|
||||
CORS_ORIGIN: ${CORS_ORIGINS:-https://localhost}
|
||||
JWT_SECRET: ${JWT_SECRET:-change_me_in_production}
|
||||
LOG_LEVEL: info
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para polling GTFS-RT Vehicle Positions
|
||||
worker:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-worker
|
||||
restart: unless-stopped
|
||||
command: ["node", "src/worker/gtfs-poller.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
@@ -91,24 +114,23 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para sincronización GTFS Static
|
||||
gtfs-static-syncer:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-gtfs-static-syncer
|
||||
restart: unless-stopped
|
||||
command: node src/worker/gtfs-static-syncer.js
|
||||
command: ["node", "src/worker/gtfs-static-syncer.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
REDIS_URL: redis://redis:6379
|
||||
GTFS_STATIC_URL: https://data.renfe.com/dataset/horarios-trenes-largo-recorrido-ave/resource/horarios-trenes-largo-recorrido-ave-gtfs.zip
|
||||
SYNC_SCHEDULE: 0 3 * * *
|
||||
SYNC_SCHEDULE: "0 3 * * *"
|
||||
LOG_LEVEL: info
|
||||
volumes:
|
||||
- gtfs_static_data:/tmp/gtfs
|
||||
@@ -117,18 +139,17 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para polling GTFS-RT Trip Updates
|
||||
trip-updates-poller:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-trip-updates-poller
|
||||
restart: unless-stopped
|
||||
command: node src/worker/trip-updates-poller.js
|
||||
command: ["node", "src/worker/trip-updates-poller.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
@@ -141,18 +162,17 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para polling GTFS-RT Service Alerts
|
||||
alerts-poller:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-alerts-poller
|
||||
restart: unless-stopped
|
||||
command: node src/worker/alerts-poller.js
|
||||
command: ["node", "src/worker/alerts-poller.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
@@ -165,18 +185,17 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para datos de flota Renfe
|
||||
renfe-fleet-poller:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-renfe-fleet-poller
|
||||
restart: unless-stopped
|
||||
command: node src/worker/renfe-fleet-poller.js
|
||||
command: ["node", "src/worker/renfe-fleet-poller.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
@@ -187,18 +206,17 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Worker para refrescar vistas de analytics
|
||||
analytics-refresher:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: worker
|
||||
image: tea.millaguie.net/millaguie/trenes-backend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-analytics-refresher
|
||||
restart: unless-stopped
|
||||
command: node src/worker/analytics-refresher.js
|
||||
command: ["node", "src/worker/analytics-refresher.js"]
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
@@ -210,49 +228,14 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# API Backend
|
||||
api:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
target: api
|
||||
container_name: trenes-api
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
DATABASE_URL: postgresql://${POSTGRES_USER:-trenes}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-trenes}
|
||||
REDIS_URL: redis://redis:6379
|
||||
CORS_ORIGIN: ${CORS_ORIGINS:-https://localhost}
|
||||
JWT_SECRET: ${JWT_SECRET}
|
||||
LOG_LEVEL: info
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
flyway:
|
||||
condition: service_completed_successfully
|
||||
networks:
|
||||
- trenes-network
|
||||
|
||||
# Frontend
|
||||
# IMPORTANTE: Las variables VITE_* deben pasarse como build args, no como environment
|
||||
# ya que se procesan en tiempo de compilación, no en runtime
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
target: production
|
||||
args:
|
||||
VITE_API_URL: ${VITE_API_URL}
|
||||
VITE_WS_URL: ${VITE_WS_URL}
|
||||
image: tea.millaguie.net/millaguie/trenes-frontend:${IMAGE_TAG:-latest}
|
||||
container_name: trenes-frontend
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
@@ -267,7 +250,7 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./nginx/prod.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- letsencrypt_certs:/etc/letsencrypt:ro
|
||||
- certbot_certs:/etc/letsencrypt:ro
|
||||
- certbot_webroot:/var/www/certbot:ro
|
||||
ports:
|
||||
- "80:80"
|
||||
@@ -288,7 +271,7 @@ services:
|
||||
image: certbot/certbot
|
||||
container_name: trenes-certbot
|
||||
volumes:
|
||||
- letsencrypt_certs:/etc/letsencrypt
|
||||
- certbot_certs:/etc/letsencrypt
|
||||
- certbot_webroot:/var/www/certbot
|
||||
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
||||
networks:
|
||||
@@ -301,10 +284,10 @@ volumes:
|
||||
driver: local
|
||||
gtfs_static_data:
|
||||
driver: local
|
||||
letsencrypt_certs:
|
||||
driver: local
|
||||
certbot_certs:
|
||||
external: true
|
||||
certbot_webroot:
|
||||
driver: local
|
||||
external: true
|
||||
|
||||
networks:
|
||||
trenes-network:
|
||||
|
||||
Reference in New Issue
Block a user