-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
110 lines (101 loc) · 3 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
variables:
KUBERNETES_MEMORY_REQUEST: "1Gi"
KUBERNETES_MEMORY_LIMIT: "1Gi"
REGISTRY_AUTH_FILE: /run/secrets/runner-job-secrets/docker_config_ci.json
RUNNER_AFTER_SCRIPT_TIMEOUT: 60m
PEBBLES_DEPLOY_IMAGE_TAG:
description: 'use custom tag for pebbles-deploy in cicd-pipeline'
value: 'main'
# Parameters for running the builds manually
BUILD_ALL_IMAGES:
description: 'Build all images regardless of changes'
value: 'false'
options:
- 'false'
- 'true'
BUILD_SINGLE_IMAGE:
description: 'Build a single image regardless of changes'
value: ''
options:
- ''
- filebeat
- k3s-autoscaler
- logstash
- pebbles-backup
- pebbles-deployer
stages:
- build
- cicd-pipeline
# We make use of all builds being identical. The build target is defined by COMPONENT in job variables.
.job_template: &job_definition
stage: build
tags: ['new-runner']
image: quay.io/buildah/stable:v1.36
rules:
# feature branch: build only images that have been modified
- if: $CI_COMMIT_BRANCH
changes:
compare_to: 'refs/heads/main'
paths:
- "container-src/$COMPONENT/**/*"
# merge to main: build changed images compared to the previous commit
- if: ($CI_COMMIT_REF_NAME == 'main' && $CI_PIPELINE_SOURCE == "push")
changes:
paths:
- "container-src/$COMPONENT/**/*"
# pipeline UI: build all images if desired
- if: $BUILD_ALL_IMAGES == 'true'
# pipeline UI: build a single image
- if: $BUILD_SINGLE_IMAGE == $COMPONENT
# Setup buildah cache for all jobs
before_script:
- |
cat > /etc/containers/registries.conf.d/cache.conf <<EOF
[[registry]]
location = "private-registry:5000"
insecure = true
EOF
script:
- cd "${CI_PROJECT_DIR}/container-src/${COMPONENT}"
- buildah build
--storage-driver vfs
--jobs 4
--layers --cache-from private-registry:5000/pebbles/cache --cache-to private-registry:5000/pebbles/cache
--tag "${CI_IMAGE_REPO_CI}/${COMPONENT}:${CI_COMMIT_REF_NAME}"
- buildah push
--storage-driver vfs
"${CI_IMAGE_REPO_CI}/${COMPONENT}:${CI_COMMIT_REF_NAME}"
build-pebbles-deployer-image:
variables:
COMPONENT: pebbles-deployer
KUBERNETES_MEMORY_REQUEST: "4Gi"
KUBERNETES_MEMORY_LIMIT: "4Gi"
<<: *job_definition
build-pebbles-backup-image:
variables:
COMPONENT: pebbles-backup
<<: *job_definition
build-logstash-image:
variables:
COMPONENT: logstash
<<: *job_definition
build-filebeat-image:
variables:
COMPONENT: filebeat
<<: *job_definition
build-k3s-autoscaler-image:
variables:
COMPONENT: k3s-autoscaler
<<: *job_definition
# call pipeline project
cicd-pipeline:
stage: cicd-pipeline
variables:
# test using current branch code and image
PEBBLES_DEPLOY_COMMIT_REF_NAME: "${CI_COMMIT_REF_NAME}"
PEBBLES_DEPLOY_IMAGE_TAG: "${PEBBLES_DEPLOY_IMAGE_TAG}"
trigger:
project: pebbles/cicd-pipeline
branch: main
strategy: depend