blob: a986488cb76b4f84c974aab12f8c9c6f19efd768 [file] [log] [blame]
Mohammed Naser12207172024-02-05 18:49:35 -05001VERSION --use-copy-link --try 0.8
2
Mohammed Naser12207172024-02-05 18:49:35 -05003lint:
4 BUILD +lint.ansible-lint
5 BUILD +lint.markdownlint
6 BUILD +lint.image-manifest
7
Mohammed Naser12207172024-02-05 18:49:35 -05008lint.markdownlint:
9 FROM davidanson/markdownlint-cli2
10 COPY --dir docs/ .markdownlint.yaml .markdownlint-cli2.jsonc /src
11 WORKDIR /src
12 TRY
13 RUN markdownlint-cli2 **
14 FINALLY
15 SAVE ARTIFACT /src/junit.xml AS LOCAL junit.xml
16 END
17
18lint.ansible-lint:
19 FROM registry.gitlab.com/pipeline-components/ansible-lint:latest
20 COPY --dir meta/ molecule/ playbooks/ plugins/ roles/ tests/ .ansible-lint CHANGELOG.md galaxy.yml /code
21 TRY
22 RUN ansible-lint -v --show-relpath -f pep8 --nocolor | ansible-lint-junit -o ansible-lint.xml
23 FINALLY
24 SAVE ARTIFACT ansible-lint.xml AS LOCAL ansible-lint.xml
25 END
26
27lint.image-manifest:
28 FROM quay.io/skopeo/stable:latest
29 COPY roles/defaults/vars/main.yml /defaults.yml
30 FOR IMAGE IN $(cat /defaults.yml | grep sha256 | cut -d' ' -f4 | sort | uniq | sed 's/:[^@]*//')
31 BUILD +lint.image-manifest.image --IMAGE ${IMAGE}
32 END
33
34lint.image-manifest.image:
35 FROM quay.io/skopeo/stable:latest
36 ARG --required IMAGE
37 RUN skopeo inspect --no-tags docker://${IMAGE} >/dev/null && echo "Manifest is valid for ${IMAGE}" || echo "Manifest is not valid for ${IMAGE}"
38
39unit.go:
40 FROM golang:1.21
41 RUN go install github.com/jstemmer/go-junit-report/v2@latest
42 COPY --dir go.mod go.sum /src
43 WORKDIR /src
44 RUN go mod download
45 COPY --dir charts/ cmd/ internal/ roles/ tools/ /src
46 TRY
47 RUN go test -v 2>&1 ./... | go-junit-report -set-exit-code > junit-go.xml
48 FINALLY
49 SAVE ARTIFACT /src/junit-go.xml AS LOCAL junit-go.xml
50 END
51
52build.collection:
53 FROM registry.gitlab.com/pipeline-components/ansible-lint:latest
54 COPY . /src
55 RUN ansible-galaxy collection build /src
56 SAVE ARTIFACT /code/*.tar.gz AS LOCAL dist/
Mohammed Naser8613c862023-04-24 17:26:51 -040057
Mohammed Naser168acc32024-01-09 17:15:26 -050058go.build:
59 FROM golang:1.21
60 WORKDIR /src
61 ARG GOOS=linux
62 ARG GOARCH=amd64
63 ARG VARIANT
64 COPY --dir go.mod go.sum ./
65 RUN go mod download
66
67libvirt-tls-sidecar.build:
68 FROM +go.build
69 ARG GOOS=linux
70 ARG GOARCH=amd64
71 ARG VARIANT
72 COPY --dir cmd internal ./
73 RUN GOARM=${VARIANT#"v"} go build -o main cmd/libvirt-tls-sidecar/main.go
74 SAVE ARTIFACT ./main
75
76libvirt-tls-sidecar.platform-image:
77 ARG TARGETPLATFORM
78 ARG TARGETARCH
79 ARG TARGETVARIANT
80 FROM --platform=$TARGETPLATFORM ./images/base+image
81 COPY \
82 --platform=linux/amd64 \
83 (+libvirt-tls-sidecar.build/main --GOARCH=$TARGETARCH --VARIANT=$TARGETVARIANT) /usr/bin/libvirt-tls-sidecar
84 ENTRYPOINT ["/usr/bin/libvirt-tls-sidecar"]
Mohammed Naser1dfea6b2024-02-09 01:04:26 -050085 ARG REGISTRY=ghcr.io/vexxhost/atmosphere
Mohammed Naser12207172024-02-05 18:49:35 -050086 SAVE IMAGE --push ${REGISTRY}/libvirt-tls-sidecar:latest
Mohammed Naser168acc32024-01-09 17:15:26 -050087
88libvirt-tls-sidecar.image:
89 BUILD --platform=linux/amd64 --platform=linux/arm64 +libvirt-tls-sidecar.platform-image
90
Mohammed Naser1de55192023-04-28 17:13:35 -040091build.wheels:
Mohammed Naser7060df82023-12-29 15:12:17 -050092 FROM ./images/builder+image
Mohammed Naser8613c862023-04-24 17:26:51 -040093 COPY pyproject.toml poetry.lock ./
Mohammed Naser1de55192023-04-28 17:13:35 -040094 ARG --required only
95 RUN poetry export --only=${only} -f requirements.txt --without-hashes > requirements.txt
Mohammed Naser8613c862023-04-24 17:26:51 -040096 RUN pip wheel -r requirements.txt --wheel-dir=/wheels
97 SAVE ARTIFACT requirements.txt
98 SAVE ARTIFACT /wheels
Mohammed Naser1de55192023-04-28 17:13:35 -040099 SAVE IMAGE --cache-hint
Mohammed Naser8613c862023-04-24 17:26:51 -0400100
Mohammed Naser1de55192023-04-28 17:13:35 -0400101build.venv:
102 ARG --required only
103 FROM +build.wheels --only ${only}
Mohammed Naser8613c862023-04-24 17:26:51 -0400104 RUN python3 -m venv /venv
105 ENV PATH=/venv/bin:$PATH
106 RUN pip install -r requirements.txt
Mohammed Naser1de55192023-04-28 17:13:35 -0400107 SAVE IMAGE --cache-hint
108
109build.venv.dev:
110 FROM +build.venv --only main,dev
Mohammed Naser8613c862023-04-24 17:26:51 -0400111 SAVE ARTIFACT /venv
112
Mohammed Naser1de55192023-04-28 17:13:35 -0400113build.venv.runtime:
114 FROM +build.venv --only main
115 SAVE ARTIFACT /venv
116
117build.collections:
118 FROM +build.venv.runtime
119 COPY charts /src/charts
120 COPY meta /src/meta
121 COPY playbooks /src/playbooks
122 COPY plugins /src/plugins
123 COPY roles /src/roles
124 COPY galaxy.yml /src/galaxy.yml
125 RUN ansible-galaxy collection install --collections-path /usr/share/ansible/collections /src
126 SAVE ARTIFACT /usr/share/ansible/collections
127 SAVE IMAGE --cache-hint
128
129image:
Michiel Piscaerb19c1cf2024-01-08 22:09:04 +0100130 ARG RELEASE=2023.1
131 FROM ./images/cloud-archive-base+image --RELEASE ${RELEASE}
Mohammed Naser1de55192023-04-28 17:13:35 -0400132 ENV ANSIBLE_PIPELINING=True
Mohammed Naseraa48ddb2023-12-30 00:11:22 -0500133 DO ./images+APT_INSTALL --PACKAGES "rsync openssh-client"
Mohammed Nasere720d782023-07-10 15:57:21 -0400134 COPY +build.venv.runtime/venv /venv
135 ENV PATH=/venv/bin:$PATH
136 COPY +build.collections/ /usr/share/ansible
Mohammed Naser1de55192023-04-28 17:13:35 -0400137 ARG tag=latest
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500138 ARG REGISTRY=ghcr.io/vexxhost/atmosphere
Mohammed Naser12207172024-02-05 18:49:35 -0500139 SAVE IMAGE --push ${REGISTRY}:${tag}
Mohammed Naser8613c862023-04-24 17:26:51 -0400140
Mohammed Naser7060df82023-12-29 15:12:17 -0500141images:
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500142 ARG REGISTRY=ghcr.io/vexxhost/atmosphere
Mohammed Naser12207172024-02-05 18:49:35 -0500143 BUILD +libvirt-tls-sidecar.image --REGISTRY=${REGISTRY}
144 BUILD ./images/barbican+image --REGISTRY=${REGISTRY}
145 BUILD ./images/cinder+image --REGISTRY=${REGISTRY}
146 BUILD ./images/cluster-api-provider-openstack+image --REGISTRY=${REGISTRY}
147 BUILD ./images/designate+image --REGISTRY=${REGISTRY}
148 BUILD ./images/glance+image --REGISTRY=${REGISTRY}
149 BUILD ./images/heat+image --REGISTRY=${REGISTRY}
150 BUILD ./images/horizon+image --REGISTRY=${REGISTRY}
151 BUILD ./images/ironic+image --REGISTRY=${REGISTRY}
152 BUILD ./images/keystone+image --REGISTRY=${REGISTRY}
153 BUILD ./images/kubernetes-entrypoint+image --REGISTRY=${REGISTRY}
154 BUILD ./images/libvirtd+image --REGISTRY=${REGISTRY}
155 BUILD ./images/magnum+image --REGISTRY=${REGISTRY}
156 BUILD ./images/manila+image --REGISTRY=${REGISTRY}
157 BUILD ./images/netoffload+image --REGISTRY=${REGISTRY}
158 BUILD ./images/neutron+image --REGISTRY=${REGISTRY}
159 BUILD ./images/nova-ssh+image --REGISTRY=${REGISTRY}
160 BUILD ./images/nova+image --REGISTRY=${REGISTRY}
161 BUILD ./images/octavia+image --REGISTRY=${REGISTRY}
162 BUILD ./images/openvswitch+image --REGISTRY=${REGISTRY}
163 BUILD ./images/ovn+images --REGISTRY=${REGISTRY}
164 BUILD ./images/placement+image --REGISTRY=${REGISTRY}
165 BUILD ./images/senlin+image --REGISTRY=${REGISTRY}
166 BUILD ./images/staffeln+image --REGISTRY=${REGISTRY}
167 BUILD ./images/tempest+image --REGISTRY=${REGISTRY}
Mohammed Naser7060df82023-12-29 15:12:17 -0500168
Mohammed Naser7a848bc2024-01-22 21:58:11 -0500169SCAN_IMAGE:
Mohammed Naser12207172024-02-05 18:49:35 -0500170 FUNCTION
Mohammed Naser7a848bc2024-01-22 21:58:11 -0500171 ARG --required IMAGE
172 # TODO(mnaser): Include secret scanning when it's more reliable.
173 RUN \
174 trivy image \
175 --skip-db-update \
176 --skip-java-db-update \
177 --scanners vuln \
178 --exit-code 1 \
179 --ignore-unfixed \
180 ${IMAGE}
181
182scan-image:
183 FROM ./images/trivy+image
184 ARG --required IMAGE
185 DO +SCAN_IMAGE --IMAGE ${IMAGE}
186
187scan-images:
188 FROM ./images/trivy+image
189 COPY roles/defaults/vars/main.yml /defaults.yml
190 # TODO(mnaser): Scan all images eventually
Mohammed Naser12207172024-02-05 18:49:35 -0500191 FOR IMAGE IN $(cat /defaults.yml | egrep -E 'ghcr.io/vexxhost|registry.atmosphere.dev' | cut -d' ' -f4 | sort | uniq)
Mohammed Naser7a848bc2024-01-22 21:58:11 -0500192 BUILD +scan-image --IMAGE ${IMAGE}
Mohammed Naser7a848bc2024-01-22 21:58:11 -0500193 END
194
Mohammed Naser8613c862023-04-24 17:26:51 -0400195pin-images:
Mohammed Naser1de55192023-04-28 17:13:35 -0400196 FROM +build.venv.dev
ricolinb8ab0172023-06-01 15:41:02 +0800197 COPY roles/defaults/vars/main.yml /defaults.yml
Mohammed Naser8613c862023-04-24 17:26:51 -0400198 COPY build/pin-images.py /usr/local/bin/pin-images
Mohammed Naser1dfea6b2024-02-09 01:04:26 -0500199 ARG REGISTRY=ghcr.io/vexxhost/atmosphere
Mohammed Naser12207172024-02-05 18:49:35 -0500200 RUN --no-cache /usr/local/bin/pin-images --registry ${REGISTRY} /defaults.yml /pinned.yml
ricolinb8ab0172023-06-01 15:41:02 +0800201 SAVE ARTIFACT /pinned.yml AS LOCAL roles/defaults/vars/main.yml
Mohammed Naserd03bba32023-04-25 12:54:58 +0000202
203gh:
204 FROM alpine:3
205 RUN apk add --no-cache github-cli
206
207trigger-image-sync:
208 FROM +gh
209 ARG --required project
210 RUN --secret GITHUB_TOKEN gh workflow run --repo vexxhost/docker-openstack-${project} sync.yml
Mohammed Naser0c428872023-09-21 12:59:20 +0000211
212image-sync:
213 FROM golang:1.19
214 ARG --required project
215 WORKDIR /src
216 COPY . /src
217 RUN --secret GITHUB_TOKEN go run ./cmd/atmosphere-ci image repo sync ${project}
Mohammed Naser7f3eb562024-01-23 16:49:57 -0500218
219mkdocs-image:
220 FROM ghcr.io/squidfunk/mkdocs-material:9.5.4
221 RUN pip install \
222 mkdocs-literate-nav
223 SAVE IMAGE mkdocs
224
225mkdocs-serve:
226 LOCALLY
227 WITH DOCKER --load=+mkdocs-image
228 RUN docker run --rm -p 8000:8000 -v ${PWD}:/docs mkdocs
229 END
230
231mkdocs-build:
232 FROM +mkdocs-image
233 COPY . /docs
234 RUN mkdocs build
Mohammed Naser39953522024-01-23 16:53:31 -0500235 RUN --push --secret GITHUB_TOKEN git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/vexxhost/atmosphere.git
Mohammed Naser7f3eb562024-01-23 16:49:57 -0500236 RUN --push mkdocs gh-deploy --force