-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gitlab-ci.yml
61 lines (58 loc) · 1.93 KB
/
build.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
.docker_login: &docker_login |
set -x
# build stage script
if ! docker info &>/dev/null; then
if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then
export DOCKER_HOST='tcp://localhost:2375'
fi
fi
if [[ -n "$CI_REGISTRY_USER" ]]; then
echo "Logging to GitLab Container Registry with CI credentials..."
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
fi
build_image:
stage: build
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-build-image/master:stable"
services:
- docker:stable-dind
variables:
BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA"
before_script:
- echo "Logging to GitLab Container Registry with CI credentials..."
- *docker_login
script:
- >-
docker build
--build-arg BUILDPACK_URL="$BUILDPACK_URL"
--build-arg HTTP_PROXY="$HTTP_PROXY"
--build-arg http_proxy="$http_proxy"
--build-arg HTTPS_PROXY="$HTTPS_PROXY"
--build-arg https_proxy="$https_proxy"
--build-arg FTP_PROXY="$FTP_PROXY"
--build-arg ftp_proxy="$ftp_proxy"
--build-arg NO_PROXY="$NO_PROXY"
--build-arg no_proxy="$no_proxy"
$AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS
--tag $BUILD_IMAGE_NAME .
- docker push "$BUILD_IMAGE_NAME"
only:
- branches
- merge_requests
- tags
release_image:
stage: release
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-build-image/master:stable"
services:
- docker:stable-dind
variables:
BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA"
RELEASE_IAMGE_NAME: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_TAG"
before_script:
- echo "Logging to GitLab Container Registry with CI credentials..."
- *docker_login
script:
- docker pull $BUILD_IMAGE_NAME
- docker tag $BUILD_IMAGE_NAME $RELEASE_IAMGE_NAME
- docker push $RELEASE_IAMGE_NAME
only:
- tags