-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
71 lines (63 loc) · 1.66 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
stages:
- test
- build
- deploy
test:
stage: test
image: elixir:1.12
except:
- master
services:
- postgres:latest
variables:
POSTGRES_DB: "webapp_test"
POSTGRES_HOST: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
MIX_ENV: "test"
before_script:
- apt-get update && apt-get -y install postgresql-client
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
- mix ecto.create
- mix ecto.migrate
script:
- mix test
- mix coveralls
- mix credo suggest --mute-exit-status
build_docker_image:
stage: build
image: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
REGISTRY_PATH: registry.gitlab.com/runhyve/webapp
IMAGE_TAG: "$REGISTRY_PATH:$CI_COMMIT_REF_SLUG"
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
before_script:
- apk add --no-cache git
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_PATH
script:
- git rev-parse --short HEAD > .vcs_version
- docker build -t $IMAGE_TAG --build-arg $SECRET_KEY_BASE -f Dockerfile.prod .
- docker push $IMAGE_TAG
deploy-production:
image: ubuntu:18.04
stage: deploy
environment:
name: production
url: https://panel.vps.serveraptor.com
only:
- master
before_script:
- apt update && apt install -y openssh-client
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$MASTER_DEPLOYMENT_IDENTITY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
script:
- ssh -i ~/.ssh/id_rsa [email protected] ./deploy_webapp.sh