feat: add production deployment flow
All checks were successful
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
All checks were successful
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
This commit is contained in:
31
Jenkinsfile
vendored
31
Jenkinsfile
vendored
@@ -45,6 +45,13 @@ pipeline {
|
|||||||
env.COMPOSE_PROJECT = 'tiptop-preprod'
|
env.COMPOSE_PROJECT = 'tiptop-preprod'
|
||||||
env.DEPLOY_NETWORK = 'tiptop-preprod'
|
env.DEPLOY_NETWORK = 'tiptop-preprod'
|
||||||
env.FRONTEND_API_URL = 'http://192.168.1.23:5002'
|
env.FRONTEND_API_URL = 'http://192.168.1.23:5002'
|
||||||
|
} else if (env.BRANCH_NAME.startsWith('release-')) {
|
||||||
|
env.DEPLOY_ENABLED = 'true'
|
||||||
|
env.DEPLOY_ENV = 'PROD'
|
||||||
|
env.COMPOSE_FILE = 'deploy/prod/docker-compose.yml'
|
||||||
|
env.COMPOSE_PROJECT = 'tiptop-prod'
|
||||||
|
env.DEPLOY_NETWORK = 'tiptop-prod'
|
||||||
|
env.FRONTEND_API_URL = 'http://192.168.1.23:5003'
|
||||||
} else {
|
} else {
|
||||||
env.DEPLOY_ENABLED = 'false'
|
env.DEPLOY_ENABLED = 'false'
|
||||||
env.DEPLOY_ENV = 'CI uniquement'
|
env.DEPLOY_ENV = 'CI uniquement'
|
||||||
@@ -195,6 +202,21 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Validation production') {
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
env.DEPLOY_ENV == 'PROD'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
steps {
|
||||||
|
timeout(time: 15, unit: 'MINUTES') {
|
||||||
|
input message: "Déployer ${IMAGE_TAG} en production ?",
|
||||||
|
ok: "Déployer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Déploiement') {
|
stage('Déploiement') {
|
||||||
when {
|
when {
|
||||||
expression {
|
expression {
|
||||||
@@ -228,13 +250,6 @@ pipeline {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$i" -eq 30 ]; then
|
if [ "$i" -eq 30 ]; then
|
||||||
echo "Le backend ${DEPLOY_ENV} ne répond pas."
|
|
||||||
|
|
||||||
docker compose \
|
|
||||||
-p "${COMPOSE_PROJECT}" \
|
|
||||||
-f "${COMPOSE_FILE}" \
|
|
||||||
ps
|
|
||||||
|
|
||||||
docker compose \
|
docker compose \
|
||||||
-p "${COMPOSE_PROJECT}" \
|
-p "${COMPOSE_PROJECT}" \
|
||||||
-f "${COMPOSE_FILE}" \
|
-f "${COMPOSE_FILE}" \
|
||||||
@@ -246,8 +261,6 @@ pipeline {
|
|||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Vérification du frontend ${DEPLOY_ENV}..."
|
|
||||||
|
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--network "${DEPLOY_NETWORK}" \
|
--network "${DEPLOY_NETWORK}" \
|
||||||
curlimages/curl:8.12.1 \
|
curlimages/curl:8.12.1 \
|
||||||
|
|||||||
80
deploy/prod/docker-compose.yml
Normal file
80
deploy/prod/docker-compose.yml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: tiptop_prod
|
||||||
|
POSTGRES_PASSWORD: tiptop_prod_password
|
||||||
|
POSTGRES_DB: the_tip_top_prod
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- tiptop_prod_postgres_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD-SHELL",
|
||||||
|
"pg_isready -U tiptop_prod -d the_tip_top_prod"
|
||||||
|
]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- tiptop-prod
|
||||||
|
|
||||||
|
backend:
|
||||||
|
image: ${REGISTRY}/the-tip-top/backend:${IMAGE_TAG}
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PORT: 5000
|
||||||
|
NODE_ENV: production
|
||||||
|
DATABASE_URL: postgresql://tiptop_prod:tiptop_prod_password@postgres:5432/the_tip_top_prod
|
||||||
|
JWT_SECRET: prod_secret_change_me
|
||||||
|
APP_URL: http://192.168.1.23:5003
|
||||||
|
|
||||||
|
MAIL_HOST: smtp.gmail.com
|
||||||
|
MAIL_PORT: 587
|
||||||
|
MAIL_USER: ""
|
||||||
|
MAIL_PASS: ""
|
||||||
|
MAIL_FROM: "The Tip Top <no-reply@tiptop.local>"
|
||||||
|
|
||||||
|
command: >
|
||||||
|
sh -c "
|
||||||
|
npx prisma migrate deploy &&
|
||||||
|
npm run init:db &&
|
||||||
|
npm start
|
||||||
|
"
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "5003:5000"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- tiptop-prod
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG}
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "5175:80"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
- tiptop-prod
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
tiptop_prod_postgres_data:
|
||||||
|
name: tiptop_prod_postgres_data
|
||||||
|
|
||||||
|
networks:
|
||||||
|
tiptop-prod:
|
||||||
|
name: tiptop-prod
|
||||||
Reference in New Issue
Block a user