Skip to content
Snippets Groups Projects
Verified Commit 989636cc authored by Sheogorath's avatar Sheogorath :european_castle:
Browse files

ci(gitlab-ci): Rework image build process to matrix

This patch reworks the image build process, to utilise GitLab matrix
build feature to generate all jobs, reducing code duplication.
parent 0aecbcb1
No related branches found
No related tags found
No related merge requests found
--- ---
include: include:
- local: 'images/**/.gitlab-ci.yaml' - local: 'images/.utils/gitlab-ci.yaml'
- local: 'charts/**/.gitlab-ci.yaml' - local: 'charts/**/.gitlab-ci.yaml'
stages: stages:
- release - release
......
dovecot-container-build: .container-matrix:
parallel:
matrix:
- IMAGE:
- dovecot
- postfix
container-build:
stage: build stage: build
image: quay.io/sheogorath/build-ah-engine:2.0.0 image: quay.io/sheogorath/build-ah-engine:2.0.0
extends: .container-matrix
before_script: before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: script:
- | - |
cd images/dovecot cd images/${IMAGE}
source .release source .release
podman build --pull \ podman build --pull \
--label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/dovecot" \ --label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/${IMAGE}" \
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \ --label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
--label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \ --label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \
--label "org.opencontainers.image.title=dovecot" \ --label "org.opencontainers.image.title=${IMAGE}" \
-t "quay.io/shivering-isles/dovecot:${release}" \ -t "quay.io/shivering-isles/${IMAGE}:${release}" \
--format docker \ --format docker \
. .
- podman push "quay.io/shivering-isles/dovecot:${release}" - podman push "quay.io/shivering-isles/dovecot:${release}"
rules: rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
changes: changes:
- images/dovecot/.release - images/${IMAGE}/.release
dovecot-container-build-dev: container-build-dev:
stage: build stage: build
image: quay.io/sheogorath/build-ah-engine:2.0.0 image: quay.io/sheogorath/build-ah-engine:2.0.0
extends: .container-matrix
before_script: before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: script:
- | - |
cd images/dovecot cd images/${IMAGE}
podman build --pull \ podman build --pull \
--label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/dovecot" \ --label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/${IMAGE}" \
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \ --label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
--label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \ --label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \
--label "org.opencontainers.image.title=$CI_PROJECT_TITLE" \ --label "org.opencontainers.image.title=${IMAGE}" \
--label "quay.expires-after=12w" \ --label "quay.expires-after=12w" \
-t "quay.io/shivering-isles/dovecot:${CI_COMMIT_SHORT_SHA}" \ -t "quay.io/shivering-isles/${IMAGE}:${CI_COMMIT_SHORT_SHA}" \
--format docker \ --format docker \
. .
- podman push "quay.io/shivering-isles/dovecot:${CI_COMMIT_SHORT_SHA}" - podman push "quay.io/shivering-isles/${IMAGE}:${CI_COMMIT_SHORT_SHA}"
rules: rules:
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"' - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
changes: changes:
- images/dovecot/ - images/${IMAGE}/*
- images/.utils/*
postfix-container-build:
stage: build
image: quay.io/sheogorath/build-ah-engine:2.0.0
before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
cd images/postfix
source .release
podman build --pull \
--label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/postfix" \
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
--label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \
--label "org.opencontainers.image.title=$CI_PROJECT_TITLE" \
-t "quay.io/shivering-isles/postfix:${release}" \
--format docker \
.
- podman push "quay.io/shivering-isles/postfix:${release}"
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
changes:
- images/postfix/.release
postfix-container-build-dev:
stage: build
image: quay.io/sheogorath/build-ah-engine:2.0.0
before_script:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
cd images/postfix
podman build --pull \
--label "org.opencontainers.image.source=$CI_PROJECT_URL/-/tree/$CI_COMMIT_SHA/images/postfix" \
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
--label "org.opencontainers.image.created=$(date --rfc-3339 ns)" \
--label "org.opencontainers.image.title=$CI_PROJECT_TITLE" \
--label "quay.expires-after=12w" \
-t "quay.io/shivering-isles/postfix:${CI_COMMIT_SHORT_SHA}" \
--format docker \
.
- podman push "quay.io/shivering-isles/postfix:${CI_COMMIT_SHORT_SHA}"
rules:
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
changes:
- images/postfix/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment