-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
50 lines (43 loc) · 1.27 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
variables:
CONTAINER_TEST_IMAGE: registry.gitlab.com/fu-marketplace/fu-marketplace-api:$CI_BUILD_REF_NAME
CONTAINER_RELEASE_IMAGE: registry.gitlab.com/fu-marketplace/fu-marketplace-api:latest
stages:
- build
- test
- cleanup
- release
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
build:
stage: build
script:
- docker build -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
test:
stage: test
script:
- docker run -d --name db postgres
- docker run -d --name elasticsearch elasticsearch
- docker run -d --name redis redis
- docker pull $CONTAINER_TEST_IMAGE
- docker run --link db:db --link elasticsearch:elasticsearch --link redis:redis -e NO_LOAD_ENV_FILE=true -e CI_TEST=true --env-file ./.env.test-ci $CONTAINER_TEST_IMAGE sh ./ci-test.sh
release-image:
stage: release
script:
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- production
cleanup_manual:
stage: cleanup
script:
- docker stop db elasticsearch redis
- docker rm db elasticsearch redis
when: manual
cleanup_test:
stage: cleanup
script:
- docker stop db elasticsearch redis
- docker rm db elasticsearch redis
when: always