feat: Add better tooling and CI

- Improve the build of the image by introducing `build.sh`.
  It can be used with `podman` or `buildah` and
  also provides a way of building a `dev` or `prod`
  image for development purposes by
  `build.sh [dev|prod]`.

- CI runs this script as well with `buildah`.

Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
This commit is contained in:
Gabriel Nützi
2024-04-23 15:41:28 +02:00
committed by Chris Evich
parent fe7deb1b10
commit 6dd52a3783
3 changed files with 92 additions and 22 deletions

View File

@@ -1,5 +1,4 @@
---
default:
image: quay.io/buildah/stable:v1.32
tags:
@@ -30,7 +29,7 @@ commit_check:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- when: never
variables:
BADRX: '^(squash!)|(fixup!)'
BADRX: "^(squash!)|(fixup!)"
script: |
dnf install -y git
shortlogtmp=$(mktemp -p '' commit_check_tmp_XXXX)
@@ -51,23 +50,4 @@ build:
before_script:
- echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
# N/B: There could be more than one merge-request open with this branch's HEAD
- |
IMAGE_TAG="${CI_COMMIT_REF_SLUG}";
if [[ -n "$CI_COMMIT_TAG" ]]; then
IMAGE_TAG="${CI_COMMIT_TAG}";
elif [[ -n "$CI_OPEN_MERGE_REQUESTS" ]]; then
IMAGE_TAG=mr$(echo "${CI_OPEN_MERGE_REQUESTS}" | cut -d, -f -1 | cut -d\! -f 2);
elif [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
IMAGE_TAG="latest";
fi
echo "Building/Pushing to: ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}";
- >-
buildah build \
--label "org.opencontainers.image.source=${CI_PROJECT_URL}" \
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
--label "org.opencontainers.image.created=$CI_JOB_STARTED_AT" \
--label "org.opencontainers.image.version=${IMAGE_TAG}" \
-t "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}" "$CI_PROJECT_DIR"
- buildah images
- buildah push "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
- scripts/build.sh