-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
57 lines (51 loc) · 1.28 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
image: docker:latest
variables:
IMAGE_TAG: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
CONTAINER_RELEASE_IMAGE: steynovich/spotweb:${CI_COMMIT_TAG}
CONTAINER_LATEST_IMAGE: steynovich/spotweb:latest
stages:
- build
- release
before_script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
build:
stage: build
services:
- name: docker:dind
alias: docker-dind
variables:
DOCKER_HOST: "tcp://docker-dind:2375"
script:
- echo "Building $IMAGE_TAG"
- docker build --rm -t $IMAGE_TAG .
- docker push $IMAGE_TAG
release:
stage: release
services:
- name: docker:dind
alias: docker-dind
variables:
DOCKER_HOST: "tcp://docker-dind:2375"
only:
- tags
script:
- echo "Releasing $CONTAINER_RELEASE_IMAGE"
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
latest:
stage: release
services:
- name: docker:dind
alias: docker-dind
variables:
DOCKER_HOST: "tcp://docker-dind:2375"
only:
- tags
script:
- echo "Releasing $CONTAINER_LATEST_IMAGE"
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $CONTAINER_LATEST_IMAGE
- docker push $CONTAINER_LATEST_IMAGE