Skip to content

Commit 9b4ff24

Browse files
author
Chloé Bretnacher
committed
workflow staging le retour du retour enfin le retour quoi
1 parent 18ff85b commit 9b4ff24

File tree

6 files changed

+136
-4
lines changed

6 files changed

+136
-4
lines changed

backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"test": "jest",
77
"dev": "ts-node-dev --respawn --transpile-only --poll ./src/index.ts",
8-
"build": "tsc"
8+
"build": "tsc",
9+
"start": "node ./dist/index.js"
910
},
1011
"author": "",
1112
"license": "ISC",

deployment/staging/.env.staging.sample

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ SERVICE_MESSAGE_URL=http://localhost:3000/service/message
2424
GATEWAY_PORT=NUMERO_DE_PORT_DU_GATEWAY
2525

2626
# variable fullstack
27-
MODE=dev || prod
27+
MODE=dev || prod
28+
29+
# variables images docker
30+
FRONTEND_IMAGE=NOM_IMAGE_FRONTEND
31+
BACKEND_IMAGE=NOM_IMAGE_BACKEND
32+
GATEWAY_IMAGE=NOM_IMAGE_GATEWAY
33+
MESSAGE_SERVICE_IMAGE=NOM_IMAGE_MESSAGE_SERVICE
34+
PICTURE_SERVICE_IMAGE=NOM_IMAGE_PICTURE_SERVICE
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
services:
2+
frontend:
3+
container_name: giftchat-staging-frontend
4+
restart: always
5+
image: ${FRONTEND_IMAGE}
6+
healthcheck:
7+
test: [ "CMD-SHELL", "curl --fail --request GET --url 'http://localhost:${FRONTEND_PORT}' || exit 1" ]
8+
interval: 10s
9+
retries: 5
10+
start_period: 20s
11+
depends_on:
12+
backend:
13+
condition: service_healthy
14+
environment:
15+
VITE_MODE: prod
16+
17+
backend:
18+
container_name: giftchat-staging-backend
19+
restart: always
20+
image: ${BACKEND_IMAGE}
21+
volumes:
22+
- ./backend/public/:/app/public/
23+
depends_on:
24+
database:
25+
condition: service_healthy
26+
healthcheck:
27+
test: [ "CMD-SHELL", 'curl --fail --request POST --header ''Content-Type: application/json'' --url ''http://localhost:${SERVEUR_PORT}'' --data ''{"query":"query { __typename }"}'' || exit 1' ]
28+
interval: 10s
29+
retries: 5
30+
start_period: 20s
31+
environment:
32+
DB_PASSWORD: ${DB_PASSWORD}
33+
DB_DATABASE: ${DB_DATABASE}
34+
DB_USER: ${DB_USER}
35+
DB_HOST: ${DB_HOST}
36+
JWT_SECRET: ${JWT_SECRET}
37+
SERVEUR_PORT: ${SERVEUR_PORT}
38+
MODE: prod
39+
INTERNAL_SECRET_KEY: ${INTERNAL_SECRET_KEY}
40+
41+
picture-service:
42+
container_name: giftchat-staging-picture-service
43+
restart: always
44+
image: ${PICTURE_SERVICE_IMAGE}
45+
volumes:
46+
- ./picture-service/public/:/app/public/
47+
healthcheck:
48+
test: [ "CMD-SHELL", 'curl --fail --request POST --header ''Content-Type: application/json'' --url ''http://localhost:${PICTURE_SERVICE_PORT}'' --data ''{"query":"query { __typename }"}'' || exit 1' ]
49+
interval: 10s
50+
retries: 5
51+
start_period: 20s
52+
environment:
53+
BACKEND_URL: ${SERVEUR_URL}
54+
CLIENT_URL: ${FRONTEND_URL}
55+
APP_PORT: ${PICTURE_SERVICE_PORT}
56+
57+
message-service:
58+
container_name: giftchat-staging-message-service
59+
restart: always
60+
image: ${MESSAGE_SERVICE_IMAGE}
61+
environment:
62+
BACKEND_URL: ${SERVEUR_URL}
63+
CLIENT_URL: ${FRONTEND_URL}
64+
MESSAGE_SERVICE_PORT: ${MESSAGE_SERVICE_PORT}
65+
INTERNAL_SECRET_KEY: ${INTERNAL_SECRET_KEY}
66+
JWT_SECRET: ${JWT_SECRET}
67+
68+
database:
69+
container_name: giftchat-staging-database
70+
image: postgres
71+
restart: always
72+
healthcheck:
73+
test: [ "CMD-SHELL", "pg_isready -d ${DB_DATABASE} -U ${DB_USER}" ]
74+
interval: 10s
75+
retries: 5
76+
start_period: 20s
77+
environment:
78+
POSTGRES_PASSWORD: ${DB_PASSWORD}
79+
POSTGRES_DB: ${DB_DATABASE}
80+
POSTGRES_USER: ${DB_USER}
81+
volumes:
82+
- ./persist/database:/var/lib/postgresql
83+
84+
gateway:
85+
container_name: giftchat-staging-gateway
86+
restart: always
87+
image: ${GATEWAY_IMAGE}
88+
ports:
89+
- ${GATEWAY_PORT}:80
90+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# chmod +x deploy_gif-chat_staging.sh
3+
4+
# Si le script crash on s'arrête
5+
set -e
6+
7+
mkdir -p log
8+
9+
# Fonction pour logger avec timestamp
10+
log() {
11+
echo "$(date '+%Y-%m-%d %H:%M:%S') $1" >> log/deploy_staging.log
12+
}
13+
14+
15+
log "script lancé"
16+
17+
# Verifie existence du fichier .env.staging
18+
if [ ! -f .env.staging ]; then
19+
log "Erreur: fichier .env.staging introuvable !"
20+
exit 1
21+
fi
22+
23+
log "pull des dernières images"
24+
docker compose --env-file .env.staging -f compose.staging.yaml pull
25+
26+
log "Arrêt et suppression des conteneurs existants"
27+
docker compose --env-file .env.staging -f compose.staging.yaml down
28+
29+
log "Démarrage des nouveaux conteneurs"
30+
docker compose --env-file .env.staging -f compose.staging.yaml up -d --remove-orphans
31+
32+
log "Déploiement terminé avec succès ! 🚀✨"

message-service/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"dev": "ts-node-dev --respawn --transpile-only --poll ./src/main.ts",
8-
"build": "tsc"
8+
"build": "tsc",
9+
"start": "node ./dist/main.js"
910
},
1011
"author": "",
1112
"license": "ISC",

picture-service/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "",
55
"scripts": {
66
"dev": "ts-node-dev --respawn --transpile-only --poll ./src/main",
7-
"build": "tsc"
7+
"build": "tsc",
8+
"start": "node ./dist/main.js"
89
},
910
"author": "",
1011
"license": "ISC",

0 commit comments

Comments
 (0)