From e87bbe26eeff947fd333c71ae713b80b14488e9a Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sat, 4 Nov 2023 23:25:23 +0100 Subject: [PATCH] added the ability to run the calendar in the docker container --- .env | 1 + docker-compose.yml | 23 ++++++++++++++++++++--- server/calendar/src/main.rs | 2 ++ webclient/nginx.conf | 3 +++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.env b/.env index af34e798f..babac248b 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ TILE_SPRITES_URL=https://raw.githubusercontent.com/maputnik/osm-liberty/gh-pages # database POSTGRES_PASSWORD=CHANGE_ME POSTGRES_USER=navigatum +POSTGRES_DB=navigatum # feedback GITHUB_TOKEN=CHANGE_ME diff --git a/docker-compose.yml b/docker-compose.yml index 4900cbfec..2e45207a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -57,8 +57,6 @@ services: depends_on: meilisearch: condition: service_healthy - required: true - restart: true healthcheck: test: wget -q --spider http://localhost:3003/api/status retries: 5 @@ -83,6 +81,25 @@ services: test: wget -q --spider http://localhost:3004/api/feedback/status retries: 5 start_period: 10s + calendar-api: + image: ghcr.io/tum-dev/navigatum-server:latest + restart: always + build: ./server + command: /bin/navigatum-calendar + environment: + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_URL: postgres:5432 + depends_on: + db: + condition: service_healthy + ports: + - "3005:3005" + healthcheck: + test: wget -q --spider http://localhost:3005/api/calendar/status + retries: 5 + start_period: 10s db: image: postgres:15 restart: unless-stopped @@ -90,7 +107,7 @@ services: PGDATA: /var/lib/postgresql/data/pgdata POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_DB: ${POSTGRES_USER} + POSTGRES_DB: ${POSTGRES_DB} volumes: - postgres-data:/var/lib/postgresql/data healthcheck: diff --git a/server/calendar/src/main.rs b/server/calendar/src/main.rs index 0c9108945..fd56d2907 100644 --- a/server/calendar/src/main.rs +++ b/server/calendar/src/main.rs @@ -22,12 +22,14 @@ async fn health_status_handler() -> HttpResponse { } use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness}; +use log::debug; use structured_logger::async_json::new_writer; use structured_logger::Builder; pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations"); fn apply_db_migrations() { + info!("Applying database migrations"); let con = &mut utils::establish_connection(); con.run_pending_migrations(MIGRATIONS) .expect("Migrations could not be applied"); diff --git a/webclient/nginx.conf b/webclient/nginx.conf index 7836966e4..f84378403 100644 --- a/webclient/nginx.conf +++ b/webclient/nginx.conf @@ -63,6 +63,9 @@ http { location /api/feedback { proxy_pass http://feedback-api:3004; } + location /api/calendar { + proxy_pass http://calendar-api:3005; + } location /cdn { proxy_pass http://data:3002; }