forked from ledermann/docker-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
48 lines (41 loc) · 1.38 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
variables:
CONTAINER_CURRENT_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_LATEST_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_STABLE_IMAGE: $CI_REGISTRY_IMAGE:stable
stages:
- test
- build
- release
before_script:
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
test:
stage: test
script:
- docker-compose -f docker-compose.test.yml build --pull
- docker-compose -f docker-compose.test.yml run --rm app sh -c "./docker/wait-for-services.sh && bundle exec rake db:create spec rubocop"
after_script:
- docker-compose -f docker-compose.test.yml run --rm app rm -rf tmp/
- docker-compose -f docker-compose.test.yml down
- docker volume rm `docker volume ls -qf dangling=true`
build:
stage: build
script:
- docker-compose -f docker-compose.production.yml build --pull
- docker tag dockerrails_app_production $CONTAINER_CURRENT_IMAGE
- docker push $CONTAINER_CURRENT_IMAGE
release-latest-image:
stage: release
script:
- docker pull $CONTAINER_CURRENT_IMAGE
- docker tag $CONTAINER_CURRENT_IMAGE $CONTAINER_LATEST_IMAGE
- docker push $CONTAINER_LATEST_IMAGE
only:
- develop
release-stable-image:
stage: release
script:
- docker pull $CONTAINER_CURRENT_IMAGE
- docker tag $CONTAINER_CURRENT_IMAGE $CONTAINER_STABLE_IMAGE
- docker push $CONTAINER_STABLE_IMAGE
only:
- master