Repository navigation
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
147 lines (132 loc) · 4.61 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
147 lines (132 loc) · 4.61 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
stages:
- validate
- resolve
- build
- scan
- kasm builder
include:
- project: 'kasm-technologies/internal/kasm_builder'
file: '/application-ci-include.yml'
- component: $CI_SERVER_FQDN/kasm-technologies/internal/qa-infrastructure/setup-rapidfort@develop
# Prevent duplicate pipelines for push events to branches that also have open MRs
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- if: $CI_PIPELINE_SOURCE == "push" && $CI_OPEN_MERGE_REQUESTS
when: never
- when: always
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_AUTH_CONFIG: ${_DOCKER_AUTH_CONFIG}
IMAGE_PREFIX: "${ORG_NAME}/postgres-private"
CANDIDATE_TAG: "candidate-${CI_COMMIT_SHORT_SHA}-${CI_PIPELINE_ID}"
default:
image: registry.gitlab.com/kasm-technologies/internal/qa-infrastructure/kasm-ci:v29.4.3
services:
- docker:29.4.3-dind
retry: 2
tags:
- oci-fixed-amd
# Resolves PG_VERSION/PG_SHA256/PGAUDIT_VERSION once per pipeline and publishes
# them as a dotenv artifact. Docker's layer cache is keyed on instruction text,
# not on what a RUN's network calls return, so a plain `docker build .` re-run
# without --no-cache would otherwise silently keep a stale resolved version.
# Resolving here and passing the values as --build-arg to the build job also
# guarantees the amd64 and arm64 legs land on identical versions, even if a new
# PostgreSQL/PGAudit release publishes mid-pipeline.
resolve-pg-versions:
stage: resolve
image: alpine:3.23
services: []
script:
- apk add --no-cache wget git
- PG_MAJOR=16
- PG_VERSION="$(wget -qO- https://ftp.postgresql.org/pub/source/ | grep -oE "href=\"v$PG_MAJOR\.[0-9]+/\"" | sed -E 's/href="v(.*)\/"/\1/' | sort -V | tail -1)"
- test -n "$PG_VERSION"
- PG_SHA256="$(wget -qO- "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2.sha256" | awk '{print $1}')"
- test -n "$PG_SHA256"
- git clone --quiet https://github.com/pgaudit/pgaudit.git /tmp/pgaudit
- PGAUDIT_VERSION="$(cd /tmp/pgaudit && git tag --list "${PG_MAJOR}.*" | grep -vE '(beta|rc)[0-9]*$' | sort -V | tail -1)"
- test -n "$PGAUDIT_VERSION"
- echo "PG_VERSION=$PG_VERSION" >> build.env
- echo "PG_SHA256=$PG_SHA256" >> build.env
- echo "PGAUDIT_VERSION=$PGAUDIT_VERSION" >> build.env
- cat build.env
artifacts:
reports:
dotenv: build.env
build:
stage: build
needs: ["resolve-pg-versions"]
extends:
- .setup_rfcurated
before_script:
- echo "$_DOCKER_AUTH_CONFIG" > /tmp/hub-config.json
- !reference [.setup_rfcurated, before_script]
script:
- jq -s '.[0] * .[1]' /tmp/hub-config.json ~/.docker/config.json > /tmp/merged.json && mv /tmp/merged.json ~/.docker/config.json
- unset DOCKER_AUTH_CONFIG
- docker build --provenance=false
--build-arg PG_VERSION=$PG_VERSION
--build-arg PG_SHA256=$PG_SHA256
--build-arg PGAUDIT_VERSION=$PGAUDIT_VERSION
-t "${IMAGE_PREFIX}:$(arch)-${CANDIDATE_TAG}" .
- docker push "${IMAGE_PREFIX}:$(arch)-${CANDIDATE_TAG}"
tags:
- ${TAG}
parallel:
matrix:
- TAG: [ oci-fixed-amd, oci-fixed-arm ]
manifest:
needs:
- build
stage: build
script:
- docker pull
"${IMAGE_PREFIX}:x86_64-${CANDIDATE_TAG}"
- docker pull
--platform linux/arm64
"${IMAGE_PREFIX}:aarch64-${CANDIDATE_TAG}"
- docker manifest push --purge "${IMAGE_PREFIX}:${CANDIDATE_TAG}" || true
- docker manifest create
"${IMAGE_PREFIX}:${CANDIDATE_TAG}"
"${IMAGE_PREFIX}:x86_64-${CANDIDATE_TAG}"
"${IMAGE_PREFIX}:aarch64-${CANDIDATE_TAG}"
- docker manifest annotate
"${IMAGE_PREFIX}:${CANDIDATE_TAG}"
"${IMAGE_PREFIX}:aarch64-${CANDIDATE_TAG}"
--os linux
--arch arm64
--variant v8
- docker manifest push --purge "${IMAGE_PREFIX}:${CANDIDATE_TAG}"
- echo published "${IMAGE_PREFIX}:${CANDIDATE_TAG}"
tags:
- oci-fixed-amd
trivy:
stage: scan
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
allow_failure: false
- allow_failure: true
script:
- echo "Using trivy $( trivy --version )"
- docker pull "${IMAGE_PREFIX}:$(arch)-${CANDIDATE_TAG}"
- bash ci-scripts/audit_justification.sh image="${IMAGE_PREFIX}:$(arch)-${CANDIDATE_TAG}" --check-justification
retry: 0
tags:
- oci-fixed-${PLATFORM}
parallel:
matrix:
- PLATFORM: [ amd, arm ]
artifacts:
when: always
expire_in: 2 weeks
paths:
- trivy-complete-report-${PLATFORM}.json
- audit-report-${PLATFORM}.json
build Kasm:
extends:
- .kasm-builder-trigger
stage: kasm builder