Commit a1712342 authored by schmidni's avatar schmidni
Browse files

Update .gitlab-ci.yml file

parent 913790b1
Pipeline #2347 failed with stages
in 4 minutes and 51 seconds
stages:
- codestyle
- test
- publish
- deploy
.test-rules:
rules:
......@@ -52,10 +54,66 @@ py38-test-job:
- apt-get install -y python3-dev build-essential postgresql-client
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h postgres -U $POSTGRES_USER $POSTGRES_DB < test_db.sql >/dev/null
- cp $DOTENV .env
- cp $ENV .env
- pip install tox
script:
- tox -e py38-tests
artifacts:
reports:
cobertura: coverage.xml
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
DOCKER_TLS_CERTDIR: ""
publish:
only:
- feature/cd
# - master
tags:
- deployment
# needs: ["py38-test-job"]
image: docker:19.03.12
stage: publish
services:
- name: docker:19.03.12-dind
command:
- /bin/sh
- -c
- |
echo "$CI_SERVER_TLS_CA_FILE" > /etc/ssl/certs/ca-cert-gitlab.seismo.ethz.ch.crt || exit
dockerd-entrypoint.sh || exit
script:
- docker build -t $TAG_COMMIT -t $TAG_LATEST .
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker push $TAG_COMMIT
- docker push $TAG_LATEST
deploy:
only:
- feature/cd
# - master
needs: ["publish"]
environment:
name: ramsis
image: alpine:latest
stage: deploy
tags:
- deployment
script:
- sed -i '$a\' $ENV && echo "TAG_COMMIT=$TAG_COMMIT" >> $ENV
- chmod og= $SERVER_RSA
- apk update && apk add openssh-client
- ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
- ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch "docker pull $TAG_COMMIT"
- ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch "mkdir -p database"
- scp -i $SERVER_RSA -o StrictHostKeyChecking=no $ENV $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch:~/.env
- scp -i $SERVER_RSA -o StrictHostKeyChecking=no docker-compose.yml $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch:~/docker-compose.yml
- scp -i $SERVER_RSA -o StrictHostKeyChecking=no ./database/init_db.sh $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch:~/database
- ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch "docker-compose down"
- ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@$CI_ENVIRONMENT_NAME.ethz.ch "docker-compose up -d"
Supports Markdown
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