-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
44 lines (39 loc) · 1.11 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
stages:
- build
- release
- deploy
- cleanup
variables:
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
BUILD_IMAGE: checkmed:$CI_BUILD_REF
DOCKER_LOGIN_USERNAME: gitlab-ci-token
DOCKER_LOGIN_PASSWORD: $CI_BUILD_TOKEN
build:
stage: build
script:
- docker build -t $BUILD_IMAGE .
release:
stage: release
script:
- docker tag $BUILD_IMAGE $CONTAINER_RELEASE_IMAGE
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master
deploy:
stage: deploy
script:
- docker-machine env checkmed-generic
- eval $(docker-machine env checkmed-generic)
- docker login -u $DOCKER_LOGIN_USERNAME -p $DOCKER_LOGIN_PASSWORD $CI_REGISTRY
- env > .env
- docker-compose -f docker-compose.production.yml pull
- docker-compose -f docker-compose.production.yml run --rm web rake db:migrate
- docker-compose -f docker-compose.production.yml up -d
only:
- master
cleanup:
stage: cleanup
script:
- bash -c "[ -z $(docker images -q $BUILD_IMAGE) ] || docker rmi $BUILD_IMAGE"
when: always