Skip to content
Snippets Groups Projects
Commit e19525c4 authored by sandcha's avatar sandcha Committed by benoit-cty
Browse files

Initialise le job de CI deploy-prod

parent a13c33a3
No related branches found
No related tags found
1 merge request!19Ajoute le job de CI deploy-prod
......@@ -147,3 +147,35 @@ deploy-integ:
# defined in: https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/environments
name: integration
when: manual
deploy-prod:
# SSH_PRIVATE_KEY and PRODUCTION_IP defined in:
# https://git.leximpact.dev/groups/leximpact/simulateur-dotations-communes/-/settings/ci_cd
# PRODUCTION_HOST_DOMAIN_NAME defined in:
# https://git.leximpact.dev/groups/leximpact/-/settings/ci_cd
stage: deploy
before_script:
# install git to have ssh-agent and ssh-add
- apt update && apt install -y git curl
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# check that we are in a container (inside Proxmox LXC container) before bypassing StrictHostKeyChecking
- '[[ -f /.dockerenv ]] && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\tLogLevel quiet\n" > ~/.ssh/config'
script:
# remove previous wheel on integration server and execute the new wheel
- ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && rm -v dist/* && exit"
- scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" -r dist/ leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/
# add the current .env configuration to the container (overwrite it if it already exists)
- scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .env leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.env
# add the current CSV data files to the container (overwrite them if they already exist)
- scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" data/*csv leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/data/
# get launch_api.py and deploy.sh on container (on SSH port 22)
- ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "mkdir -p $CI_PROJECT_NAME/.gitlab/ci/ && exit"
- scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .gitlab/ci/launch_api.py leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.gitlab/ci/launch_api.py
- scp -o "ProxyCommand ssh gitlabci@$PRODUCTION_HOST_DOMAIN_NAME nc -w 1 %h 22" .gitlab/ci/deploy.sh leximpact@$PRODUCTION_IP:$CI_PROJECT_NAME/.gitlab/ci/deploy.sh
# use a ssh relay to connect to the host containing the runner allowed to access the artifacts (wheel)
- ssh -J gitlabci@$PRODUCTION_HOST_DOMAIN_NAME leximpact@$PRODUCTION_IP "cd $CI_PROJECT_NAME && bash .gitlab/ci/deploy.sh && exit"
environment:
# defined in: https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-back/-/environments
name: production
when: manual
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment