Compare commits

...

10 Commits

Author SHA1 Message Date
874110f2e4 fix: make podman build work on containerd 2024-11-04 19:43:41 +00:00
4fc073c80f Merge latest ci-tools-lib 2024-11-04 19:42:38 +00:00
e63f58052a Squashed '.ci/' changes from 2c44e4f..3feaf6f
3feaf6f chore: migrate to main branch
a392836 feat: migrate all buildah cmds to podman only
d67a80e feat: make push and rm-image more resilient, prevent exit codes
8e202d4 fix: do not add non-existent images
6ef8d28 feat: ensure bash and safe exec
06fcff5 feat: improve image cleanup to incl. all tags and repositories
47b4da4 feat: add suport for trivyignore file

git-subtree-dir: .ci
git-subtree-split: 3feaf6fa96531b40c56945e3a7d6731f40bc52e2
2024-11-04 19:42:38 +00:00
f99c9aae1d Merge pull request 'chore(deps): update jenkins/inbound-agent:alpine-jdk21 docker digest to ce5fe24' (#10) from renovate/jenkins-inbound-agent-alpine-jdk21 into master
Reviewed-on: #10
2024-08-09 13:33:02 +00:00
d9107d1a7b fix: use proper dir for xdg-run on Jenkins 2024-08-09 13:32:15 +00:00
48c133f095 fix: use proper dir for xdg-run on Jenkins 2024-08-09 13:28:37 +00:00
6f498eff58 chore(deps): update jenkins/inbound-agent:alpine-jdk21 docker digest to ce5fe24 2024-08-09 03:06:54 +00:00
621c2035c6 fix: ensure xdg-run dir exists on mounted fs 2024-07-24 10:27:38 +00:00
a165073521 feat: sunc contrib templates for Trivy from 0.53 release 2024-07-15 13:04:42 +00:00
16dcaef4f7 fix: Fix trivy, config location 2024-06-25 17:10:00 +00:00
5 changed files with 42 additions and 28 deletions

View File

@ -1,3 +1,13 @@
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
.SILENT: ; # no need for @
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
.PHONY: all # All targets are accessible for user
.DEFAULT: help # Running Make will run the help target
# Parse version from latest git semver tag
GIT_TAG ?= $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
@ -23,13 +33,6 @@ ifneq ($(TRIVY_REMOTE),)
TRIVY_OPTS ::= --server $(TRIVY_REMOTE)
endif
.SILENT: ; # no need for @
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
.PHONY: all # All targets are accessible for user
.DEFAULT: help # Running Make will run the help target
help: ## Show Help
grep -E '^[a-zA-Z_-]+:.*?## .*$$' .ci/podman.mk | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@ -40,27 +43,28 @@ fmt:: ## auto format source
lint:: ## Lint source
build: ## Build the app
buildah build --rm --layers -t $(IMAGE):$(TAG)-$(_ARCH) --build-arg TAG=$(TAG) --build-arg ARCH=$(_ARCH) --platform linux/$(_ARCH) .
podman build --rm --layers -t $(IMAGE):$(TAG)-$(_ARCH) --build-arg TAG=$(TAG) --build-arg ARCH=$(_ARCH) --platform linux/$(_ARCH) .
test:: ## test built artificats
scan: ## Scan image using trivy
echo "Scanning $(IMAGE):$(TAG)-$(_ARCH) using Trivy $(TRIVY_REMOTE)"
trivy image $(TRIVY_OPTS) --quiet --no-progress localhost/$(IMAGE):$(TAG)-$(_ARCH)
trivy image $(TRIVY_OPTS) --quiet --no-progress --ignorefile ./.trivyignore.yaml localhost/$(IMAGE):$(TAG)-$(_ARCH)
# first tag and push all actual images
# create new manifest for each tag and add all available TAG-ARCH before pushing
push: ecr-login ## push images to registry
for t in $(TAG) latest $(EXTRA_TAGS); do \
for t in $(TAG) latest $(EXTRA_TAGS); do
echo "Tagging image with $(REGISTRY)/$(IMAGE):$${t}-$(ARCH)"
buildah tag $(IMAGE):$(TAG)-$(_ARCH) $(REGISTRY)/$(IMAGE):$${t}-$(_ARCH); \
buildah manifest rm $(IMAGE):$$t || true; \
buildah manifest create $(IMAGE):$$t; \
for a in $(ALL_ARCHS); do \
buildah manifest add $(IMAGE):$$t $(REGISTRY)/$(IMAGE):$(TAG)-$$a; \
done; \
podman tag $(IMAGE):$(TAG)-$(_ARCH) $(REGISTRY)/$(IMAGE):$${t}-$(_ARCH)
podman manifest rm $(IMAGE):$$t || true
podman manifest create $(IMAGE):$$t
for a in $(ALL_ARCHS); do
podman image exists $(REGISTRY)/$(IMAGE):$$t-$$a && \
podman manifest add $(IMAGE):$$t containers-storage:$(REGISTRY)/$(IMAGE):$$t-$$a
done
echo "Pushing manifest $(IMAGE):$$t"
buildah manifest push --all $(IMAGE):$$t docker://$(REGISTRY)/$(IMAGE):$$t; \
podman manifest push --all $(IMAGE):$$t docker://$(REGISTRY)/$(IMAGE):$$t
done
ecr-login: ## log into AWS ECR public
@ -73,12 +77,15 @@ rm-remote-untagged: ## delete all remote untagged and in-dev images, keep 10 tag
clean:: ## clean up source folder
rm-image:
test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH) > /dev/null
test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || echo "Error: Removing image failed"
for t in $(TAG) latest $(EXTRA_TAGS); do
for a in $(ALL_ARCHS); do
podman image exists $(IMAGE):$$t-$$a && podman image rm -f $(IMAGE):$$t-$$a || true
done
done
## some useful tasks during development
ci-pull-upstream: ## pull latest shared .ci subtree
git subtree pull --prefix .ci ssh://git@git.zero-downtime.net/ZeroDownTime/ci-tools-lib.git master --squash -m "Merge latest ci-tools-lib"
git subtree pull --prefix .ci ssh://git@git.zero-downtime.net/ZeroDownTime/ci-tools-lib.git main --squash -m "Merge latest ci-tools-lib"
create-repo: ## create new AWS ECR public repository
aws ecr-public create-repository --repository-name $(IMAGE) --region $(REGION)

View File

@ -2,7 +2,7 @@
# https://hub.docker.com/r/jenkins/inbound-agent/tags
FROM jenkins/inbound-agent:alpine-jdk21@sha256:a7e633f06d8a1af720e30cd5421b8ba58230ec34af250a07d61cba0df88c587b
FROM jenkins/inbound-agent:alpine-jdk21@sha256:ce5fe247069abd73c82d40ae5c6c400ead2c12f7be854be368d64893afc2663a
ARG BUILDUSER=jenkins
@ -41,10 +41,11 @@ RUN echo -e "$BUILDUSER:100000:65535" > /etc/subuid && \
RUN sed -i -e 's/exec \$JAVA_BIN/podman system service -t0\&\n exec \$JAVA_BIN/' /usr/local/bin/jenkins-agent
ENV XDG_RUNTIME_DIR=/home/$BUILDUSER/agent/xdg-run
ENV XDG_CONFIG_HOME=/home/$BUILDUSER
ENV XDG_CONFIG_HOME=/home/$BUILDUSER/.config
ENV BUILDAH_ISOLATION=chroot
ENV _CONTAINERS_USERNS_CONFIGURED=""
# Not needed on containerd and actually breaks `podman build`
#ENV BUILDAH_ISOLATION=chroot
#ENV _CONTAINERS_USERNS_CONFIGURED=""
# Until we setup the logging and metrics pipelines in OTEL
ENV OTEL_LOGS_EXPORTER=none

2
Jenkinsfile vendored
View File

@ -2,4 +2,4 @@ library identifier: 'zdt-lib@master', retriever: modernSCM(
[$class: 'GitSCMSource',
remote: 'https://git.zero-downtime.net/ZeroDownTime/ci-tools-lib.git'])
buildPodman name: 'jenkins-podman', trivyFail: 'NONE'
buildPodman name: 'jenkins-podman'

View File

@ -1,4 +1,4 @@
#!/bin/sh
mkdir -p $HOME/xdg-run $HOME/containers/run $HOME/containers/storage
mkdir -p $XDG_RUNTIME_DIR
/usr/local/bin/jenkins-agent

View File

@ -14,8 +14,12 @@
</testcase>
{{- end }}
</testsuite>
{{- $failures := len .Misconfigurations }}
<testsuite tests="{{ $failures }}" failures="{{ $failures }}" name="{{ .Target }}" errors="0" skipped="0" time="">
{{- if .MisconfSummary }}
<testsuite tests="{{ add .MisconfSummary.Successes .MisconfSummary.Failures }}" failures="{{ .MisconfSummary.Failures }}" name="{{ .Target }}" errors="0" skipped="{{ .MisconfSummary.Exceptions }}" time="">
{{- else }}
<testsuite tests="0" failures="0" name="{{ .Target }}" errors="0" skipped="0" time="">
{{- end }}
{{- if not (eq .Type "") }}
<properties>
<property name="type" value="{{ .Type }}"></property>
@ -23,7 +27,9 @@
{{- end -}}
{{ range .Misconfigurations }}
<testcase classname="{{ .Type }}" name="[{{ .Severity }}] {{ .ID }}" time="">
{{- if (eq .Status "FAIL") }}
<failure message="{{ escapeXML .Title }}" type="description">{{ escapeXML .Description }}</failure>
{{- end }}
</testcase>
{{- end }}
</testsuite>