-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
81 lines (70 loc) · 2.71 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
71
72
73
74
75
76
77
78
79
80
81
# Copyright (C) 2022 Christian Berger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Which Docker image shall be used on the GitLab runner?
image: registry.git.chalmers.se/courses/dit638/students/docker/docker:19.03.3
# Details about how to connect to the Docker service to run this build.
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
#New
DOCKER_DRIVER: overlay2
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.3.1/buildx-v0.3.1.linux-amd64
BUILDX_BUILDER: Multiplatform_builder
BUILDX_PLATFORM: linux/amd64,linux/arm64,linux/arm/v7
IMAGE: registry.git.chalmers.se/courses/dit638/students/2022-group-02
services:
- name: registry.git.chalmers.se/courses/dit638/students/docker/docker:19.03.3-dind
alias: docker
stages:
- build
- deploy
# Display information before we start the build.
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# This section describes what shall be done to build and test the project.
build-and-test:
only:
- branches
tags:
- docker-build
stage: build
script:
- docker build -f Dockerfile .
# This section describes what shall be done to deploy artefacts from the project.
release:
when: on_success
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v(\d+\.)?(\d+\.)?(\*|\d+)$/
tags:
- docker-build
stage: deploy
before_script:
- mkdir -p $HOME/.docker/cli-plugins/
- wget -O $HOME/.docker/cli-plugins/docker-buildx $BUILDX_URL
- chmod a+x $HOME/.docker/cli-plugins/docker-buildx
- "echo -e '{\n \"experimental\": \"enabled\"\n}' | tee $HOME/.docker/config.json"
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use --driver docker-container --name ${BUILDX_BUILDER} --platform=${BUILDX_PLATFORM}
- docker buildx inspect --bootstrap ${BUILDX_BUILDER}
- docker buildx ls
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
script:
- docker buildx build --platform=${BUILDX_PLATFORM} -t ${IMAGE}:"$CI_COMMIT_TAG" --push "."