diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2767e407584a0c248e88f60ad8179b7a08eab230..981e84e4ae19179dd6473ce101ab830395cd9f1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,8 @@ -build: +stages: + - build + - deploy + +build_docker: stage: build image: name: gcr.io/kaniko-project/executor:debug @@ -7,3 +11,26 @@ build: - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" >/kaniko/.docker/config.json - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME --cleanup - /kaniko/executor --context $CI_PROJECT_DIR/docker/nginx --dockerfile $CI_PROJECT_DIR/docker/nginx/Dockerfile --destination $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_NAME --cleanup + only: + - master + +deploy_demo-master: + stage: deploy + environment: + name: demo-master + url: http://demo-master.biscuit-sis.org + image: + name: debian:buster-slim + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "$SSH_KNOWN_HOSTS" >~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + script: + - ssh root@demo-master.biscuit-sis.org docker-compose -p biscuit-demo-master -f /dev/stdin pull <docker-compose.yaml + - ssh root@demo-master.biscuit-sis.org env NGIINX_HTTP_PORT=80 docker-compose -p biscuit-demo-master -f /dev/stdin up -d <docker-compose.yaml + only: + - master diff --git a/docker-compose.yaml b/docker-compose.yaml index 7f31ad1dc09cfd0543458258db86c2cf755e65e5..51c5430219032f6f37f06cbf1f450ba198ef27d8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -32,7 +32,7 @@ services: - biscuit_media:/srv/media - biscuit_static:/srv/static ports: - - 8080:80 + - ${NGINX_HTTP_PORT:-8080}:80 depends_on: - app