Commit 03755fc7 authored by Romain Hunault's avatar Romain Hunault

Deploy in prod

parent 485f07d8
......@@ -73,26 +73,43 @@ coverage:
- test:functional
coverage: '/TOTAL.*\s+(\d+%)$/'
deploy:test:
.deploy:template:
image: docker:stable
stage: deploy
only:
- branches
when: manual
variables:
PUBLISH_USER: root
PUBLISH_URL: spot.test.ecloud.global
GIT_STRATEGY: none
SPOT_HOSTNAME: spot.test.ecloud.global
dependencies: []
variables:
DEPLOY_FOLDER: /mnt/data
before_script:
- 'which ssh-agent || ( apk --update add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY_TEST" | tr -d '\r' | ssh-add - > /dev/null
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh -2 $PUBLISH_USER@$PUBLISH_URL "cd /root/my-spot/ && git fetch && git checkout $CI_COMMIT_SHA"
- ssh -2 $PUBLISH_USER@$PUBLISH_URL "SPOT_HOSTNAME=$SPOT_HOSTNAME && export SPOT_HOSTNAME && cd /root/my-spot/ && docker-compose pull && docker-compose up -d --build --force-recreate"
- ssh -2 $PUBLISH_USER@$PUBLISH_URL "mkdir -p ${DEPLOY_FOLDER} && cd ${DEPLOY_FOLDER} && if [ ! -d ${CI_PROJECT_NAME} ] ; then git clone ${CI_PROJECT_URL}.git ; fi && cd ${CI_PROJECT_NAME} && git fetch && git checkout $CI_COMMIT_SHA"
- ssh -2 $PUBLISH_USER@$PUBLISH_URL "SPOT_HOSTNAME=$SPOT_HOSTNAME && export SPOT_HOSTNAME && cd ${DEPLOY_FOLDER}/${CI_PROJECT_NAME} && docker-compose pull && docker-compose up -d --build --force-recreate"
test:
extends: .deploy:template
variables:
PUBLISH_USER: root
PUBLISH_URL: spot.test.ecloud.global
GIT_STRATEGY: none
SPOT_HOSTNAME: spot.test.ecloud.global
SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY_TEST}
prod:
extends: .deploy:template
only:
- master
variables:
PUBLISH_USER: root
PUBLISH_URL: spot.ecloud.global
GIT_STRATEGY: none
SPOT_HOSTNAME: spot.ecloud.global
SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY_PROD}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment