mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
ci: adjust build arguments (#2772)
The build arguments `VCS_REF` and `VCS_VER` were renamed and given proper values according to their names. 1. `VCS_REVISION` holds the current SHA sum of the (git) HEAD pointer 2. `VCS_VERSION` now holds the contents of the `VERSION` file, i.e. a semver version tag (one can now inspect the image and find a proper version tag in the `org.opencontainers.image.version` label) The build arguments were given defaults in order to allow the `generic_build` and `generic_test` workflows to omit them (as they are not need there anyways). When publishing images, this is fina as the cache will rebuild almost all of the image except the last few layers which are `LABEL`s anyways.
This commit is contained in:
parent
f8e1bb0f42
commit
6113b99881
3
.github/workflows/generic_build.yml
vendored
3
.github/workflows/generic_build.yml
vendored
|
@ -83,9 +83,6 @@ jobs:
|
||||||
uses: docker/build-push-action@v3.1.1
|
uses: docker/build-push-action@v3.1.1
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
build-args: |
|
|
||||||
VCS_REF=${{ github.sha }}
|
|
||||||
VCS_VER=${{ github.ref }}
|
|
||||||
# Build at least the AMD64 image (which runs against the test suite).
|
# Build at least the AMD64 image (which runs against the test suite).
|
||||||
platforms: ${{ inputs.platforms }}
|
platforms: ${{ inputs.platforms }}
|
||||||
# Paired with steps `actions/cache` and `Replace cache` (replace src with dest):
|
# Paired with steps `actions/cache` and `Replace cache` (replace src with dest):
|
||||||
|
|
9
.github/workflows/generic_publish.yml
vendored
9
.github/workflows/generic_publish.yml
vendored
|
@ -66,13 +66,18 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: 'Acquire the image version'
|
||||||
|
id: get-version
|
||||||
|
shell: bash
|
||||||
|
run: echo "::set-output name=version::$(<VERSION)"
|
||||||
|
|
||||||
- name: 'Build and publish images'
|
- name: 'Build and publish images'
|
||||||
uses: docker/build-push-action@v3.1
|
uses: docker/build-push-action@v3.1
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
build-args: |
|
build-args: |
|
||||||
VCS_REF=${{ github.sha }}
|
VCS_REVISION=${{ github.sha }}
|
||||||
VCS_VER=${{ github.ref }}
|
VCS_VERSION=${{ steps.get-version.outputs.version }}
|
||||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
tags: ${{ steps.prep.outputs.tags }}
|
||||||
|
|
3
.github/workflows/generic_test.yml
vendored
3
.github/workflows/generic_test.yml
vendored
|
@ -37,9 +37,6 @@ jobs:
|
||||||
uses: docker/build-push-action@v3.1.1
|
uses: docker/build-push-action@v3.1.1
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
build-args: |
|
|
||||||
VCS_REF=${{ github.sha }}
|
|
||||||
VCS_VER=${{ github.ref }}
|
|
||||||
tags: mailserver-testing:ci
|
tags: mailserver-testing:ci
|
||||||
# Export the built image to the Docker host for use with BATS:
|
# Export the built image to the Docker host for use with BATS:
|
||||||
load: true
|
load: true
|
||||||
|
|
|
@ -281,8 +281,8 @@ COPY target/scripts/helpers /usr/local/bin/helpers
|
||||||
#
|
#
|
||||||
|
|
||||||
FROM stage-base AS stage-final
|
FROM stage-base AS stage-final
|
||||||
ARG VCS_REF
|
ARG VCS_REVISION=unknown
|
||||||
ARG VCS_VER
|
ARG VCS_VERSION=edge
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
EXPOSE 25 587 143 465 993 110 995 4190
|
EXPOSE 25 587 143 465 993 110 995 4190
|
||||||
|
@ -312,5 +312,5 @@ LABEL org.opencontainers.image.documentation="https://github.com/docker-mailserv
|
||||||
LABEL org.opencontainers.image.source="https://github.com/docker-mailserver/docker-mailserver"
|
LABEL org.opencontainers.image.source="https://github.com/docker-mailserver/docker-mailserver"
|
||||||
# ARG invalidates cache when it is used by a layer (implicitly affects RUN)
|
# ARG invalidates cache when it is used by a layer (implicitly affects RUN)
|
||||||
# Thus to maximize cache, keep these lines last:
|
# Thus to maximize cache, keep these lines last:
|
||||||
LABEL org.opencontainers.image.revision=${VCS_REF}
|
LABEL org.opencontainers.image.revision=${VCS_REVISION}
|
||||||
LABEL org.opencontainers.image.version=${VCS_VER}
|
LABEL org.opencontainers.image.version=${VCS_VERSION}
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -1,8 +1,8 @@
|
||||||
SHELL = /bin/bash
|
SHELL = /bin/bash
|
||||||
|
|
||||||
NAME ?= mailserver-testing:ci
|
NAME ?= mailserver-testing:ci
|
||||||
VCS_REF = $(shell git rev-parse --short HEAD)
|
VCS_REVISION = $(shell git rev-parse --short HEAD)
|
||||||
VCS_VER = $(shell git describe --tags --contains --always)
|
VCS_VERSION = $(shell cat VERSION)
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
# --- Generic Build Targets ---------------------
|
# --- Generic Build Targets ---------------------
|
||||||
|
@ -11,7 +11,7 @@ VCS_VER = $(shell git describe --tags --contains --always)
|
||||||
all: lint build backup generate-accounts tests clean
|
all: lint build backup generate-accounts tests clean
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker build -t $(NAME) . --build-arg VCS_VER=$(VCS_VER) --build-arg VCS_REF=$(VCS_REF)
|
docker build -t $(NAME) . --build-arg VCS_VERSION=$(VCS_VERSION) --build-arg VCS_REVISION=$(VCS_REVISION)
|
||||||
|
|
||||||
backup:
|
backup:
|
||||||
# if backup directory exist, clean hasn't been called, therefore
|
# if backup directory exist, clean hasn't been called, therefore
|
||||||
|
|
Loading…
Reference in a new issue