diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 44a530fc0966b2176f0e077f04c9ee1177cbb6d4..f7555d0c25610525aec268a0f0989a5d21f37897 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ stages: - test - build - docker + - deploy format: image: golang:alpine @@ -35,3 +36,20 @@ build: - mkdir -p /kaniko/.docker - 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:latest + +deploy: + stage: deploy + image: kroniak/ssh-client + 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 + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + script: + - ssh mike@sch.mikesweb.site "mkdir -p ~/deploy/vox" + - scp docker-compose.yml mike@sch.mikesweb.site:~/deploy/vox/ + - ssh root@sch.mikesweb.site "cd /home/mike/deploy/vox; docker-compose up -d --remove-orphans" + only: + - master \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..0308563ed177f4e49eafbfa2cc44ae008db3a192 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: "3" +services: + vox: + image: registry.mikesweb.site/vox:latest + container_name: vox + restart: unless-stopped + environment: + - POSTGRES=vox_postgres + env_file: + - secrets.env + labels: + - traefik.http.services.vox.loadbalancer.server.port=8080 + - traefik.http.routers.vox.rule=Host(`vox.mikesweb.site`) + - traefik.http.routers.vox.tls=true + - traefik.http.routers.vox.tls.certresolver=myresolver + + postgres: + image: postgres:latest + container_name: vox_postgres + environment: + - POSTGRES_PASSWORD=postgres + volumes: + - vox_postgres:/var/lib/postgresql/data + +volumes: + vox_postgres: