diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 02c2fdb..2372c50 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,11 +21,11 @@ setup: # script: # - npm run test:unit -# test:e2e: -# image: node -# stage: test -# script: -# - npm run test:e2e +test:e2e: + image: node:12-browsers + stage: test + script: + - npm run test:e2e es:lint: image: node:12 @@ -74,22 +74,25 @@ deploy_dev: - ssh $DEV_SSH_USER@$DEV_SSH_HOST "docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY" - ssh $DEV_SSH_USER@$DEV_SSH_HOST "bash ~/deployment-frontend/deploy_dev.sh \"$IMAGE_NAME\"" -# deploy_production: -# stage: deploy -# image: alpine:latest -# environment: -# name: production -# url: https://sika.sahkoinsinoorikilta.fi -# when: manual -# only: -# - master -# before_script: -# - pwd -# - apk add --update openssh -# - ssh -V -# - mkdir -p ~/.ssh -# - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa -# - chmod 600 ~/.ssh/id_rsa -# - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config -# script: -# - ssh $PROD_SSH_USER@$PROD_SSH_HOST "zsh ~/deploy-frontend.sh" +deploy_production: + stage: deploy + image: docker:stable + only: + - production + environment: + name: production + url: sika.sik.party + when: manual + variables: + DOCKER_HOST: $CI_DOCKER_HOST + DOCKER_TLS_VERIFY: 1 + before_script: + - mkdir -p ~/.docker + - echo "$TLSCACERT" > ~/.docker/ca.pem + - echo "$TLSCERT" > ~/.docker/cert.pem + - echo "$TLSKEY" > ~/.docker/key.pem + - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY" + script: + - docker stack deploy --with-registry-auth -c stack-compose.yml "$SERVICE_NAME" + after_script: + - docker logout "$CI_REGISTRY" diff --git a/stack-compose.yml b/stack-compose.yml new file mode 100644 index 0000000..2520368 --- /dev/null +++ b/stack-compose.yml @@ -0,0 +1,15 @@ +version: '3.4' + +services: + frontend: + image: registry.gitlab.com/sahkoinsinoorikilta/vtmk/web2.0-frontend:latest + deploy: + replicas: 1 + restart_policy: + condition: on-failure + update_config: + order: start-first + ports: + - 3000:3000 + environment: + API_URL: ${API_URL}