ci: migrate deployments to VPS HTTPS infrastructure
Some checks failed
THE-TIP-TOP-MULTIBRANCH/pipeline/head There was a failure building this commit

This commit is contained in:
2026-08-14 22:45:59 +00:00
parent b15d8458c8
commit 2bbd2d16e4
4 changed files with 116 additions and 75 deletions

62
Jenkinsfile vendored
View File

@@ -8,8 +8,7 @@ pipeline {
} }
environment { environment {
REGISTRY = "localhost:5000" REGISTRY = "registry.wk-archi-o24a-4-5-g4.fr"
SERVER_IP = "192.168.1.95"
BACKEND_IMAGE = "${REGISTRY}/the-tip-top/backend" BACKEND_IMAGE = "${REGISTRY}/the-tip-top/backend"
FRONTEND_IMAGE = "${REGISTRY}/the-tip-top/frontend" FRONTEND_IMAGE = "${REGISTRY}/the-tip-top/frontend"
@@ -49,7 +48,7 @@ pipeline {
env.COMPOSE_PROJECT = 'tiptop-dev' env.COMPOSE_PROJECT = 'tiptop-dev'
env.DEPLOY_NETWORK = 'tiptop-dev' env.DEPLOY_NETWORK = 'tiptop-dev'
env.FRONTEND_API_URL = "http://${SERVER_IP}:5001" env.FRONTEND_API_URL = "https://api-dev.dsp5-archi-o24a-4-5-g4.fr"
} else if (env.BRANCH_NAME.startsWith('release-')) { } else if (env.BRANCH_NAME.startsWith('release-')) {
env.DEPLOY_ENABLED = 'true' env.DEPLOY_ENABLED = 'true'
@@ -59,7 +58,7 @@ 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://${SERVER_IP}:5002" env.FRONTEND_API_URL = "https://api-preprod.dsp5-archi-o24a-4-5-g4.fr"
} else if (env.BRANCH_NAME == 'main') { } else if (env.BRANCH_NAME == 'main') {
env.DEPLOY_ENABLED = 'true' env.DEPLOY_ENABLED = 'true'
@@ -69,7 +68,7 @@ pipeline {
env.COMPOSE_PROJECT = 'tiptop-prod' env.COMPOSE_PROJECT = 'tiptop-prod'
env.DEPLOY_NETWORK = 'tiptop-prod' env.DEPLOY_NETWORK = 'tiptop-prod'
env.FRONTEND_API_URL = "http://${SERVER_IP}:5003" env.FRONTEND_API_URL = "https://api.dsp5-archi-o24a-4-5-g4.fr"
} else { } else {
env.DEPLOY_ENABLED = 'false' env.DEPLOY_ENABLED = 'false'
@@ -85,7 +84,6 @@ pipeline {
echo "Tag Docker : ${env.IMAGE_TAG}" echo "Tag Docker : ${env.IMAGE_TAG}"
echo "Environnement : ${env.DEPLOY_ENV}" echo "Environnement : ${env.DEPLOY_ENV}"
echo "Déploiement activé : ${env.DEPLOY_ENABLED}" echo "Déploiement activé : ${env.DEPLOY_ENABLED}"
echo "Serveur : ${env.SERVER_IP}"
echo "API frontend : ${env.FRONTEND_API_URL}" echo "API frontend : ${env.FRONTEND_API_URL}"
} }
} }
@@ -229,19 +227,34 @@ pipeline {
} }
stage('Publication dans le Registry') { stage('Publication dans le Registry') {
when { when {
expression { expression {
env.DEPLOY_ENABLED == 'true' env.DEPLOY_ENABLED == 'true'
}
}
steps {
sh '''
docker push "${BACKEND_IMAGE}:${IMAGE_TAG}"
docker push "${FRONTEND_IMAGE}:${IMAGE_TAG}"
'''
}
} }
}
steps {
withCredentials([
usernamePassword(
credentialsId: 'registry-credentials',
usernameVariable: 'REGISTRY_USER',
passwordVariable: 'REGISTRY_PASSWORD'
)
]) {
sh '''
echo "${REGISTRY_PASSWORD}" | \
docker login "${REGISTRY}" \
-u "${REGISTRY_USER}" \
--password-stdin
docker push "${BACKEND_IMAGE}:${IMAGE_TAG}"
docker push "${FRONTEND_IMAGE}:${IMAGE_TAG}"
'''
}
}
}
}
stage('Validation production') { stage('Validation production') {
when { when {
@@ -333,12 +346,13 @@ pipeline {
} }
post { post {
always { always {
sh ''' sh '''
docker rm -f "${CI_DATABASE}" 2>/dev/null || true docker logout "${REGISTRY}" 2>/dev/null || true
docker network rm "${CI_NETWORK}" 2>/dev/null || true docker rm -f "${CI_DATABASE}" 2>/dev/null || true
''' docker network rm "${CI_NETWORK}" 2>/dev/null || true
} '''
}
success { success {
echo """ echo """

View File

@@ -9,7 +9,7 @@ services:
POSTGRES_DB: the_tip_top_db POSTGRES_DB: the_tip_top_db
volumes: volumes:
- tiptop_postgres_dev_data:/var/lib/postgresql/data - tiptop_dev_postgres_data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: ["CMD-SHELL", "pg_isready -U tiptop -d the_tip_top_db"] test: ["CMD-SHELL", "pg_isready -U tiptop -d the_tip_top_db"]
@@ -30,14 +30,10 @@ services:
environment: environment:
PORT: 5000 PORT: 5000
NODE_ENV: development
DATABASE_URL: postgresql://tiptop:tiptop_dev_password@postgres:5432/the_tip_top_db DATABASE_URL: postgresql://tiptop:tiptop_dev_password@postgres:5432/the_tip_top_db
JWT_SECRET: dev_secret_change_me JWT_SECRET: dev_secret_change_me
APP_URL: http://192.168.1.23:5001 APP_URL: https://api-dev.dsp5-archi-o24a-4-5-g4.fr
MAIL_HOST: smtp.gmail.com
MAIL_PORT: 587
MAIL_USER: ""
MAIL_PASS: ""
MAIL_FROM: "The Tip Top <no-reply@tiptop.local>"
command: > command: >
sh -c " sh -c "
@@ -46,11 +42,18 @@ services:
npm start npm start
" "
ports:
- "5001:5000"
networks: networks:
- tiptop-dev - tiptop-dev
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-dev-api.rule=Host(`api-dev.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-dev-api.entrypoints=websecure"
- "traefik.http.routers.tiptop-dev-api.tls=true"
- "traefik.http.routers.tiptop-dev-api.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-dev-api.loadbalancer.server.port=5000"
frontend: frontend:
image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG} image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG}
@@ -59,17 +62,26 @@ services:
depends_on: depends_on:
- backend - backend
ports:
- "5173:80"
networks: networks:
- tiptop-dev - tiptop-dev
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-dev.rule=Host(`dev.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-dev.entrypoints=websecure"
- "traefik.http.routers.tiptop-dev.tls=true"
- "traefik.http.routers.tiptop-dev.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-dev.loadbalancer.server.port=80"
volumes: volumes:
tiptop_postgres_dev_data: tiptop_dev_postgres_data:
external: true name: tiptop_dev_postgres_data
name: the-tip-top_tiptop_postgres_dev_data
networks: networks:
tiptop-dev: tiptop-dev:
name: tiptop-dev name: tiptop-dev
proxy:
external: true

View File

@@ -12,11 +12,7 @@ services:
- tiptop_preprod_postgres_data:/var/lib/postgresql/data - tiptop_preprod_postgres_data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: test: ["CMD-SHELL", "pg_isready -U tiptop_preprod -d the_tip_top_preprod"]
[
"CMD-SHELL",
"pg_isready -U tiptop_preprod -d the_tip_top_preprod"
]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 10 retries: 10
@@ -37,12 +33,7 @@ services:
NODE_ENV: preproduction NODE_ENV: preproduction
DATABASE_URL: postgresql://tiptop_preprod:tiptop_preprod_password@postgres:5432/the_tip_top_preprod DATABASE_URL: postgresql://tiptop_preprod:tiptop_preprod_password@postgres:5432/the_tip_top_preprod
JWT_SECRET: preprod_secret_change_me JWT_SECRET: preprod_secret_change_me
APP_URL: http://192.168.1.23:5002 APP_URL: https://api-preprod.dsp5-archi-o24a-4-5-g4.fr
MAIL_HOST: smtp.gmail.com
MAIL_PORT: 587
MAIL_USER: ""
MAIL_PASS: ""
MAIL_FROM: "The Tip Top Preprod <no-reply@tiptop.local>"
command: > command: >
sh -c " sh -c "
@@ -51,11 +42,18 @@ services:
npm start npm start
" "
ports:
- "5002:5000"
networks: networks:
- tiptop-preprod - tiptop-preprod
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-preprod-api.rule=Host(`api-preprod.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-preprod-api.entrypoints=websecure"
- "traefik.http.routers.tiptop-preprod-api.tls=true"
- "traefik.http.routers.tiptop-preprod-api.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-preprod-api.loadbalancer.server.port=5000"
frontend: frontend:
image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG} image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG}
@@ -64,11 +62,18 @@ services:
depends_on: depends_on:
- backend - backend
ports:
- "5174:80"
networks: networks:
- tiptop-preprod - tiptop-preprod
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-preprod.rule=Host(`preprod.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-preprod.entrypoints=websecure"
- "traefik.http.routers.tiptop-preprod.tls=true"
- "traefik.http.routers.tiptop-preprod.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-preprod.loadbalancer.server.port=80"
volumes: volumes:
tiptop_preprod_postgres_data: tiptop_preprod_postgres_data:
@@ -77,3 +82,6 @@ volumes:
networks: networks:
tiptop-preprod: tiptop-preprod:
name: tiptop-preprod name: tiptop-preprod
proxy:
external: true

View File

@@ -12,11 +12,7 @@ services:
- tiptop_prod_postgres_data:/var/lib/postgresql/data - tiptop_prod_postgres_data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: test: ["CMD-SHELL", "pg_isready -U tiptop_prod -d the_tip_top_prod"]
[
"CMD-SHELL",
"pg_isready -U tiptop_prod -d the_tip_top_prod"
]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 10 retries: 10
@@ -37,13 +33,7 @@ services:
NODE_ENV: production NODE_ENV: production
DATABASE_URL: postgresql://tiptop_prod:tiptop_prod_password@postgres:5432/the_tip_top_prod DATABASE_URL: postgresql://tiptop_prod:tiptop_prod_password@postgres:5432/the_tip_top_prod
JWT_SECRET: prod_secret_change_me JWT_SECRET: prod_secret_change_me
APP_URL: http://192.168.1.23:5003 APP_URL: https://api.dsp5-archi-o24a-4-5-g4.fr
MAIL_HOST: smtp.gmail.com
MAIL_PORT: 587
MAIL_USER: ""
MAIL_PASS: ""
MAIL_FROM: "The Tip Top <no-reply@tiptop.local>"
command: > command: >
sh -c " sh -c "
@@ -52,11 +42,18 @@ services:
npm start npm start
" "
ports:
- "5003:5000"
networks: networks:
- tiptop-prod - tiptop-prod
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-prod-api.rule=Host(`api.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-prod-api.entrypoints=websecure"
- "traefik.http.routers.tiptop-prod-api.tls=true"
- "traefik.http.routers.tiptop-prod-api.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-prod-api.loadbalancer.server.port=5000"
frontend: frontend:
image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG} image: ${REGISTRY}/the-tip-top/frontend:${IMAGE_TAG}
@@ -65,11 +62,18 @@ services:
depends_on: depends_on:
- backend - backend
ports:
- "5175:80"
networks: networks:
- tiptop-prod - tiptop-prod
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.tiptop-prod.rule=Host(`dsp5-archi-o24a-4-5-g4.fr`) || Host(`www.dsp5-archi-o24a-4-5-g4.fr`)"
- "traefik.http.routers.tiptop-prod.entrypoints=websecure"
- "traefik.http.routers.tiptop-prod.tls=true"
- "traefik.http.routers.tiptop-prod.tls.certresolver=letsencrypt"
- "traefik.http.services.tiptop-prod.loadbalancer.server.port=80"
volumes: volumes:
tiptop_prod_postgres_data: tiptop_prod_postgres_data:
@@ -78,3 +82,6 @@ volumes:
networks: networks:
tiptop-prod: tiptop-prod:
name: tiptop-prod name: tiptop-prod
proxy:
external: true