From c460f37026fb6779b32000c315aa4ba2f6cb9e10 Mon Sep 17 00:00:00 2001 From: gisele-igore Date: Tue, 4 Apr 2023 11:54:32 +0200 Subject: [PATCH] Resolved merge conflict by keeping README.md file. --- .gitignore | 1 + README.md | 34 ++++++++++++++++++++++++++++++++++ docker-compose.yml | 38 ++++++++++++++++++++++++++++++-------- package.json | 4 ++-- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index f4470a3b..e505544c 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* +id_rsa diff --git a/README.md b/README.md index 98dec841..f5a7b54b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ # leCoffre [Owner: Elise Hautefaye] + +### A. Docker Launch application +#### 1) Local RSA Key for docker build + +1) Create a file named : `id_rsa` in /src +2) Get the RSA Private key on Keeper who is allowed to read the `leCoffre-ressources repo` +3) You can find Key on Keeper inside the folder **LeCoffre project > SSH Key** +4) Copy past in the `id_rsa` that you created step 1 + +:rotating_light: **Be aware to have the id_rsa included in your .gitignore! This ssh shouldn't be push on github** + +> You need to do the same task in the front and back repo. + +#### 2) Build images + +###### a- Back end +`docker build -t "le-coffre-back" -f Dockerfiles/Dockerfile.api .` +###### b- Front end +`docker build -t "le-coffre-front" -f Dockerfiles/Dockerfile.front .` + +#### 3) Docker Run + +`docker run --env-file .env -p 3000:3000 le-coffre-back` + +#### 4) Docker Compose + +Docker compose allow to launch multiples images +1) **le-coffre-front** +2) **le-coffre-back** +3) **postgres** + +> Launch your docker container with following command : + +`docker compose up -d` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d7f1c3d0..92f5eff6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,38 @@ volumes: db_storage: services: - postgres: - image: lecoffrelocal - restart: always + front-end: + image: "le-coffre-front" + ports: + - 3000:${FRONT_PORT} environment: - - POSTGRES_USER - - POSTGRES_PASSWORD - - POSTGRES_DB - - DATABASE_USERNAME + - FRONT_PORT + backend: + image: "le-coffre-back" + ports: + - 3001:${APP_PORT} + environment: + - DATABASE_HOSTNAME + - DATABASE_PORT + - DATABASE_USER - DATABASE_PASSWORD - DATABASE_NAME + - APP_LABEL + - APP_PORT + - APP_ROOT_URL + - API_ROOT_URL + - DEV_PRISMA_STUDIO_DB_URL + + postgres: + image: postgres + restart: always + environment: + - DATABASE_HOSTNAME + - DATABASE_PORT + - DATABASE_USER + - DATABASE_PASSWORD + - DATABASE_NAME + - POSTGRES_PASSWORD ports: - ${DATABASE_PORT}:5432 volumes: @@ -21,7 +43,7 @@ services: - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh healthcheck: - test: ["CMD-SHELL", "pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] + test: ["CMD-SHELL", "pg_isready -h localhost -U ${DATABASE_USER} -d ${DATABASE_NAME}"] interval: 5s timeout: 5s retries: 10 \ No newline at end of file diff --git a/package.json b/package.json index ad973943..bc3e47db 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,13 @@ }, "scripts": { "build": "tsc", - "api:start": "node ./dist/entries/App.js", + "api:start": "npm run migrate && node ./dist/entries/App.js", "start": "tsc && npm run api:start", "dev": "nodemon -V", "api:dev": "nodemon -V --exec 'tsc && npm run api:start'", "build:test": "tsc && mocha ./dist/entries/Test.js", "format": "prettier --write src", - "migrate": "" + "migrate": "npx prisma migrate deploy" }, "repository": { "type": "git",