changed workflow for use build-args from versions.env in buildx builder
Some checks failed
Docker Build Smart Logic / Build amd64 & arm64 (push) Failing after 5s
Some checks failed
Docker Build Smart Logic / Build amd64 & arm64 (push) Failing after 5s
This commit is contained in:
@@ -19,6 +19,7 @@ jobs:
|
||||
runs-on: buildx-multiarch
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
uses: http://git.pi-farm.de/pi-farm/checkout@v4
|
||||
with:
|
||||
@@ -134,23 +135,57 @@ jobs:
|
||||
|
||||
echo "DOCKER_TAGS=$TAGS" >> $GITEA_ENV
|
||||
|
||||
- name: Load versions.env
|
||||
id: load_env
|
||||
run: |
|
||||
echo "Lade versions.env"
|
||||
set -a
|
||||
source versions.env
|
||||
set +a
|
||||
# Schreibe die wichtigsten Variablen ins GITEA_ENV für weitere Steps
|
||||
echo "BASE_IMAGE=$BASE_IMAGE" >> $GITEA_ENV
|
||||
echo "APP_VERSION=$APP_VERSION" >> $GITEA_ENV
|
||||
echo "TARGET_PLATFORMS=$TARGET_PLATFORMS" >> $GITEA_ENV
|
||||
echo "IMAGE_NAME=${REGISTRY_HOST}/${IMAGE_BASE}" >> $GITEA_ENV
|
||||
echo "CACHE_IMAGE_NAME=${REGISTRY_HOST}/${IMAGE_BASE}-cache" >> $GITEA_ENV
|
||||
echo "VERSION=${{ gitea.ref_name }}" >> $GITEA_ENV
|
||||
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITEA_ENV
|
||||
|
||||
- name: Build & push multiarch
|
||||
if: steps.check_files.outputs.should_build == 'true'
|
||||
run: |
|
||||
IFS=',' read -ra TAGARRAY <<< "$DOCKER_TAGS"
|
||||
TAG_ARGS=""
|
||||
for tag in "${TAGARRAY[@]}"; do
|
||||
TAG_ARGS="$TAG_ARGS -t $tag"
|
||||
done
|
||||
echo "== Multiarch Build Start =="
|
||||
|
||||
# Build amd64
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--platform linux/amd64 \
|
||||
-f ${AMD64_DOCKERFILE} \
|
||||
--build-arg BUILD_DATE=${BUILD_DATE} \
|
||||
--build-arg VERSION=${VERSION} \
|
||||
$TAG_ARGS \
|
||||
--build-arg BASE_IMAGE=$BASE_IMAGE \
|
||||
--build-arg APP_VERSION=$APP_VERSION \
|
||||
--label org.opencontainers.image.version=$APP_VERSION \
|
||||
--label org.opencontainers.image.created=$BUILD_DATE \
|
||||
-t ${CACHE_IMAGE_NAME}:${VERSION}-amd64 \
|
||||
--push .
|
||||
|
||||
# Build arm64
|
||||
docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
-f ${ARM64_DOCKERFILE} \
|
||||
--build-arg BASE_IMAGE=$BASE_IMAGE \
|
||||
--build-arg APP_VERSION=$APP_VERSION \
|
||||
--label org.opencontainers.image.version=$APP_VERSION \
|
||||
--label org.opencontainers.image.created=$BUILD_DATE \
|
||||
-t ${CACHE_IMAGE_NAME}:${VERSION}-arm64 \
|
||||
--push .
|
||||
|
||||
# Merge into manifest
|
||||
docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION} \
|
||||
${CACHE_IMAGE_NAME}:${VERSION}-amd64 \
|
||||
${CACHE_IMAGE_NAME}:${VERSION}-arm64
|
||||
|
||||
echo "== Multiarch Build Complete =="
|
||||
|
||||
|
||||
- name: Generate SBOM
|
||||
run: |
|
||||
docker sbom ${IMAGE_NAME}:edge > sbom.spdx.json || true
|
||||
|
||||
Reference in New Issue
Block a user