From 9ad61bd6aa9128f0c45ecfc9f2b7a37a73c68064 Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Thu, 15 Dec 2022 17:14:50 +0100 Subject: [PATCH] fix dockerization --- .env | 11 ++++++----- .env.dist | 10 +++++----- README.md | 6 ++++++ docker-compose.yml | 20 +++++++++++++------- src/main.ts | 3 ++- 5 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.env b/.env index 7632b9a..fbd4f0b 100644 --- a/.env +++ b/.env @@ -1,12 +1,13 @@ # SERVICE -SERVICE_CONTAINER=v3_user -SERVICE_PORT=3001 +SERVICE_CONTAINER=v3-user +SERVICE_URL=0.0.0.0 +SERVICE_PORT=5001 # PRISMA DATABASE_URL="postgresql://user:user@db:5432/user?schema=public" # POSTGRES -POSTGRES_CONTAINER=v3_user_db +POSTGRES_CONTAINER=v3-user-db POSTGRES_IMAGE=postgres:15.0 POSTGRES_DB=user POSTGRES_PASSWORD=user @@ -14,8 +15,8 @@ POSTGRES_USER=user POSTGRES_PORT=5401 # PGADMIN -PGADMIN_CONTAINER=v3_user_pgadmin +PGADMIN_CONTAINER=v3-user-pgadmin PGADMIN_IMAGE=dpage/pgadmin4:6.12 -PGADMIN_EMAIL=it@mobicoo.org +PGADMIN_EMAIL=it@mobicoop.org PGADMIN_PASSWORD=user PGADMIN_PORT=8401 diff --git a/.env.dist b/.env.dist index 12c42be..fbd4f0b 100644 --- a/.env.dist +++ b/.env.dist @@ -1,13 +1,13 @@ # SERVICE -SERVICE_CONTAINER=v3_user -SERVICE_PORT=3001 -SERVICE_URL=localhost:3001 +SERVICE_CONTAINER=v3-user +SERVICE_URL=0.0.0.0 +SERVICE_PORT=5001 # PRISMA DATABASE_URL="postgresql://user:user@db:5432/user?schema=public" # POSTGRES -POSTGRES_CONTAINER=v3_user_db +POSTGRES_CONTAINER=v3-user-db POSTGRES_IMAGE=postgres:15.0 POSTGRES_DB=user POSTGRES_PASSWORD=user @@ -15,7 +15,7 @@ POSTGRES_USER=user POSTGRES_PORT=5401 # PGADMIN -PGADMIN_CONTAINER=v3_user_pgadmin +PGADMIN_CONTAINER=v3-user-pgadmin PGADMIN_IMAGE=dpage/pgadmin4:6.12 PGADMIN_EMAIL=it@mobicoop.org PGADMIN_PASSWORD=user diff --git a/README.md b/README.md index 6d0b63b..35ddd21 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ docker-compose up -d The app runs automatically on the port defined in `SERVICE_PORT` of `.env` file (default : _3001_). +You then need to set the appropriate rights for PGAdmin container : + +```bash +sudo chown -R 5050:5050 postgresql/.pgadmin_data +``` + ## Database migration Before using the app, you need to launch the database migration : diff --git a/docker-compose.yml b/docker-compose.yml index df732bd..b0a7d50 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,11 +13,13 @@ services: - .env command: npm run start:dev ports: - - "${SERVICE_PORT:-3001}:5000" + - "${SERVICE_PORT:-5001}:${SERVICE_PORT:-5001}" depends_on: - db networks: - - mobicoop-v3 + v3-network: + aliases: + - v3-user-api db: container_name: ${POSTGRES_CONTAINER} @@ -32,7 +34,9 @@ services: volumes: - ./postgresql/.db_data:/var/lib/postgresql/data:rw networks: - - mobicoop-v3 + v3-network: + aliases: + - v3-user-db pgadmin: container_name: ${PGADMIN_CONTAINER} @@ -47,11 +51,13 @@ services: - ./postgresql/.pgadmin_data:/var/lib/pgadmin:rw restart: unless-stopped networks: - - mobicoop-v3 + v3-network: + aliases: + - v3-user-pgadmin depends_on: - db networks: - mobicoop-v3: - external: - name: mobicoop-v3 + v3-network: + name: v3-network + driver: bridge diff --git a/src/main.ts b/src/main.ts index 593b588..7673cd1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,7 +14,8 @@ async function bootstrap() { __dirname, 'modules/users/adapters/primaries/user.proto', ), - url: '0.0.0.0:5000', + url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT, + loader: { keepCase: true }, }, }, );