forked from influxdata/influxdb-relay
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
70 lines (63 loc) · 2.39 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
58
59
60
61
62
63
64
65
66
67
68
69
70
stages:
- build
.docker_build_template: &docker_build_template
stage: build
before_script:
# Configure registries.
- |
export REGISTRIES=""
# Login to gitlab docker registry.
if [ -n "$CI_REGISTRY_IMAGE" ]; then
echo "Logging in to gitlab registry."
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" \
$CI_REGISTRY
export REGISTRIES="$REGISTRIES $CI_REGISTRY_IMAGE"
echo "Logged in to gitlab registry."
else
echo "No credentials provided for gitlab registry, skipping."
fi
# Login to other registry.
if [ -n "$EXT_REGISTRY" ] && \
[ -n "$EXT_REGISTRY_IMAGE" ] && \
[ -n "$EXT_REGISTRY_USER" ] && \
[ -n "$EXT_REGISTRY_PASSWORD" ]
then
echo "Logging in to $EXT_REGISTRY."
docker login -u "$EXT_REGISTRY_USER" -p "$EXT_REGISTRY_PASSWORD" \
"$EXT_REGISTRY"
export REGISTRIES="$REGISTRIES $EXT_REGISTRY_IMAGE"
echo "Logged in to $EXT_REGISTRY."
else
echo "No credentials provided for external registry, skipping."
fi
# Login to dockerhub.
if [ -n "$DOCKERHUB_IMAGE" ] && \
[ -n "$DOCKERHUB_USER" ] && \
[ -n "$DOCKERHUB_PASSWORD" ]
then
echo "Logging in to dockerhub."
docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_PASSWORD"
export REGISTRIES="$REGISTRIES $DOCKERHUB_IMAGE"
echo "Logged in to dockerhub."
else
echo "No credentials provided for dockerhub, skipping."
fi
# Check if any registry configured.
if [ -z "$REGISTRIES" ]; then
echo "No registries configured, exiting."
exit 1
fi
tags:
- builder
dependencies: []
build_gocky_image:
<<: *docker_build_template
script:
- docker build --rm -t gcr.io/mist-ops/gocky:$CI_COMMIT_SHA .
- docker tag gcr.io/mist-ops/gocky:$CI_COMMIT_SHA gcr.io/mist-ops/gocky:$CI_COMMIT_REF_SLUG
- docker push gcr.io/mist-ops/gocky:$CI_COMMIT_SHA
- docker push gcr.io/mist-ops/gocky:$CI_COMMIT_REF_SLUG
- docker tag gcr.io/mist-ops/gocky:$CI_COMMIT_SHA mist/gocky:$CI_COMMIT_SHA
- docker tag gcr.io/mist-ops/gocky:$CI_COMMIT_SHA mist/gocky:$CI_COMMIT_REF_SLUG
- docker push mist/gocky:$CI_COMMIT_SHA
- docker push mist/gocky:$CI_COMMIT_REF_SLUG