-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
67 lines (59 loc) · 2.07 KB
/
.gitlab-ci.yml
File metadata and controls
67 lines (59 loc) · 2.07 KB
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
image: docker:latest
# ref https://docs.gitlab.com/ee/user/packages/container_registry/#build-and-push-images-using-gitlab-cicd
stages:
- build
- test
- push
services:
- name: docker:dind
alias: localhost # https://stackoverflow.com/questions/57059851/gitlab-ci-gives-curl-7-failed-to-connect-to-localhost-port-8090-connection-r
variables:
CONTAINER_TAG_FOR_TESTS: youtous/rainloop:test-image
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_RELEASE_TAGGED_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
before_script:
# docker login asks for the password to be passed through stdin for security
# we use $CI_JOB_TOKEN here which is a special token provided by GitLab
- echo -n $CI_REGISTRY_PASSWORD | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
# build the image and push it on gitlab registry
build:
stage: build
script:
- docker build --pull -t "$CONTAINER_TEST_IMAGE" .
- docker push "$CONTAINER_TEST_IMAGE"
test:
image: tmaier/docker-compose:latest
stage: test
variables:
TEST_TIMEOUT_IN_SECONDS: 120
TEST_LOCALHOST_HOSTNAME: docker
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- apk add --no-cache --update make bash curl
- apk add --no-cache --upgrade grep
script:
- docker pull "$CONTAINER_TEST_IMAGE"
- docker tag "$CONTAINER_TEST_IMAGE" "$CONTAINER_TAG_FOR_TESTS"
- make tests-no-build
# push "latest" image to the registry
build-latest:
stage: push
only:
- master # latest from master only
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
# push "tagged" image to the registry
build-release:
stage: push
# only start a release on tags of master (not other branches)
only:
- tags # latest from master only
except:
- branches
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_TAGGED_IMAGE
- docker push $CONTAINER_RELEASE_TAGGED_IMAGE