fix dockerization

This commit is contained in:
Gsk54 2022-12-15 17:14:50 +01:00
parent f6d322fc76
commit 9ad61bd6aa
5 changed files with 32 additions and 18 deletions

11
.env
View File

@ -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

View File

@ -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

View File

@ -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 :

View File

@ -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

View File

@ -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 },
},
},
);