-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
63 lines (57 loc) · 1.99 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
default:
image: docker:27
services:
- name: docker:27-dind
alias: docker
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
.before_script_template: &before-script
before_script:
- apk add curl git jq
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker context create docker-container
- docker buildx create --use docker-container --driver docker-container --buildkitd-flags '--allow-insecure-entitlement network.host'
stages:
- build
docker-build-dev:
stage: build
except:
- master
- main
interruptible: true
<<: *before-script
script:
- mkdir -p container && cp -r scripts/container/* container
- docker buildx build
--platform linux/amd64,linux/arm64
--allow network.host
--provenance false
--pull
--cache-from type=registry,ref=$CI_REGISTRY/chrisleekr/homelab-infrastructure:cache
--cache-to type=registry,ref=$CI_REGISTRY/chrisleekr/homelab-infrastructure:cache,oci-mediatypes=true,image-manifest=true
--tag $CI_REGISTRY/chrisleekr/homelab-infrastructure:dev-${CI_COMMIT_REF_SLUG}
--push .
docker-build:
stage: build
only:
- master
- main
<<: *before-script
# Use --provenance false to avoid the following error:
# https://gitlab.com/gitlab-org/gitlab/-/issues/389577
script:
- mkdir -p container && cp -r scripts/container/* container
- docker buildx build
--platform linux/amd64,linux/arm64
--allow network.host
--provenance false
--pull
--cache-from type=registry,ref=$CI_REGISTRY/chrisleekr/homelab-infrastructure:cache
--cache-to type=registry,ref=$CI_REGISTRY/chrisleekr/homelab-infrastructure:cache,oci-mediatypes=true,image-manifest=true
--tag $CI_REGISTRY/chrisleekr/homelab-infrastructure:latest
--tag $CI_REGISTRY/chrisleekr/homelab-infrastructure:v$(cat version.txt)
--push .