diff --git a/backend/package-lock.json b/backend/package-lock.json index f2edc2c..669e472 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -14,6 +14,7 @@ "dotenv": "^16.4.5", "exceljs": "^4.4.0", "express": "^4.19.2", + "express-async-errors": "^3.1.1", "jsonwebtoken": "^9.0.2", "pdfkit": "^0.15.0", "pg": "^8.12.0" @@ -915,6 +916,15 @@ "url": "https://opencollective.com/express" } }, + "node_modules/express-async-errors": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/express-async-errors/-/express-async-errors-3.1.1.tgz", + "integrity": "sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng==", + "license": "ISC", + "peerDependencies": { + "express": "^4.16.2" + } + }, "node_modules/fast-csv": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/fast-csv/-/fast-csv-4.3.6.tgz", diff --git a/backend/package.json b/backend/package.json index e76d8db..554b2a6 100644 --- a/backend/package.json +++ b/backend/package.json @@ -14,6 +14,7 @@ "dotenv": "^16.4.5", "exceljs": "^4.4.0", "express": "^4.19.2", + "express-async-errors": "^3.1.1", "jsonwebtoken": "^9.0.2", "pdfkit": "^0.15.0", "pg": "^8.12.0" diff --git a/backend/src/index.js b/backend/src/index.js index ec8aec7..905ed33 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,5 +1,6 @@ require('dotenv').config(); const express = require('express'); +require('express-async-errors'); const cookieParser = require('cookie-parser'); const cors = require('cors'); diff --git a/docker-compose.yml b/docker-compose.yml index 666be51..d7145dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - db: + presencia-db: image: postgres:16-alpine restart: unless-stopped environment: @@ -16,15 +16,15 @@ services: timeout: 5s retries: 10 - backend: + presencia-backend: build: ./backend restart: unless-stopped depends_on: - db: + presencia-db: condition: service_healthy environment: PORT: 4790 - PGHOST: db + PGHOST: presencia-db PGPORT: 5432 PGUSER: presencia PGPASSWORD: R4dsITu0vuigNQQwNlvj0agVyHupSyX @@ -37,11 +37,11 @@ services: ports: - "4790:4790" - frontend: + presencia-frontend: build: ./frontend restart: unless-stopped depends_on: - - backend + - presencia-backend ports: - "8781:80" diff --git a/frontend/nginx.conf b/frontend/nginx.conf index fa2e011..504c797 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -5,8 +5,14 @@ server { root /usr/share/nginx/html; index index.html; + # Resolve the backend hostname at request time (via Docker's embedded DNS) + # instead of once at startup, so a recreated backend container is picked + # up without needing to restart/reload this nginx. + resolver 127.0.0.11 valid=30s; + location /api/ { - proxy_pass http://backend:4790/api/; + set $backend_upstream http://presencia-backend:4790; + proxy_pass $backend_upstream/api/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;