From db34d3f39a8d88cecd6889d665bcded851b74849 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 18 Aug 2023 16:39:18 +0200 Subject: [PATCH] Docker build dont ignore ci env vars (#2238) close #2236 --- .woodpecker/docker.yml | 15 +++++++++++++++ docker/Dockerfile.agent.alpine.multiarch | 2 +- docker/Dockerfile.agent.multiarch | 2 +- docker/Dockerfile.cli.alpine.multiarch | 2 +- docker/Dockerfile.cli.multiarch | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.woodpecker/docker.yml b/.woodpecker/docker.yml index 6c74ee077..ac23327cd 100644 --- a/.woodpecker/docker.yml +++ b/.woodpecker/docker.yml @@ -18,6 +18,7 @@ variables: - &platforms_server 'linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/riscv64' - &platforms_preview 'linux/amd64' - &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le' + - &build_args 'CI_COMMIT_SHA=${CI_COMMIT_SHA},CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH},CI_COMMIT_TAG=${CI_COMMIT_TAG}' # vars used on push / tag events only - publish_logins: &publish_logins @@ -201,6 +202,7 @@ steps: dockerfile: docker/Dockerfile.agent.multiarch platforms: *platforms_preview tag: pull_${CI_COMMIT_PULL_REQUEST} + build_args: *build_args when: event: pull_request @@ -213,6 +215,7 @@ steps: platforms: *platforms_release tag: [next, "next-${CI_COMMIT_SHA:0:10}"] logins: *publish_logins + build_args: *build_args when: branch: ${CI_REPO_DEFAULT_BRANCH} event: push @@ -226,6 +229,7 @@ steps: platforms: *platforms_alpine tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"] logins: *publish_logins + build_args: *build_args when: branch: ${CI_REPO_DEFAULT_BRANCH} event: push @@ -239,6 +243,7 @@ steps: platforms: *platforms_release tag: ${CI_COMMIT_BRANCH##release/} logins: *publish_logins + build_args: *build_args when: branch: release/* event: push @@ -252,6 +257,7 @@ steps: platforms: *platforms_alpine tag: ${CI_COMMIT_BRANCH##release/} logins: *publish_logins + build_args: *build_args when: branch: release/* event: push @@ -266,6 +272,7 @@ steps: # remove 'latest' on older version branches to avoid accidental downgrade tag: [latest, "${CI_COMMIT_TAG}"] logins: *publish_logins + build_args: *build_args when: event: tag @@ -279,6 +286,7 @@ steps: # remove 'latest-alpine' on older version branches to avoid accidental downgrade tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"] logins: *publish_logins + build_args: *build_args when: event: tag @@ -295,6 +303,7 @@ steps: dockerfile: docker/Dockerfile.cli.multiarch platforms: *platforms_preview tag: pull_${CI_COMMIT_PULL_REQUEST} + build_args: *build_args when: event: pull_request @@ -307,6 +316,7 @@ steps: platforms: *platforms_release tag: [next, "next-${CI_COMMIT_SHA:0:10}"] logins: *publish_logins + build_args: *build_args when: branch: ${CI_REPO_DEFAULT_BRANCH} event: push @@ -320,6 +330,7 @@ steps: platforms: *platforms_alpine tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"] logins: *publish_logins + build_args: *build_args when: branch: ${CI_REPO_DEFAULT_BRANCH} event: push @@ -333,6 +344,7 @@ steps: platforms: *platforms_release tag: ${CI_COMMIT_BRANCH##release/} logins: *publish_logins + build_args: *build_args when: branch: release/* event: push @@ -346,6 +358,7 @@ steps: platforms: *platforms_alpine tag: ${CI_COMMIT_BRANCH##release/} logins: *publish_logins + build_args: *build_args when: branch: release/* event: push @@ -360,6 +373,7 @@ steps: # remove 'latest' on older version branches to avoid accidental downgrade tag: [latest, "${CI_COMMIT_TAG}"] logins: *publish_logins + build_args: *build_args when: event: tag @@ -373,5 +387,6 @@ steps: # remove 'latest-alpine' on older version branches to avoid accidental downgrade tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"] logins: *publish_logins + build_args: *build_args when: event: tag diff --git a/docker/Dockerfile.agent.alpine.multiarch b/docker/Dockerfile.agent.alpine.multiarch index d4fba3e66..494899b25 100644 --- a/docker/Dockerfile.agent.alpine.multiarch +++ b/docker/Dockerfile.agent.alpine.multiarch @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build WORKDIR /src COPY . . -ARG TARGETOS TARGETARCH +ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ make build-agent diff --git a/docker/Dockerfile.agent.multiarch b/docker/Dockerfile.agent.multiarch index 6bcf5b766..baebcfb67 100644 --- a/docker/Dockerfile.agent.multiarch +++ b/docker/Dockerfile.agent.multiarch @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build WORKDIR /src COPY . . -ARG TARGETOS TARGETARCH +ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ make build-agent diff --git a/docker/Dockerfile.cli.alpine.multiarch b/docker/Dockerfile.cli.alpine.multiarch index cd1f98dfe..0a41dd67d 100644 --- a/docker/Dockerfile.cli.alpine.multiarch +++ b/docker/Dockerfile.cli.alpine.multiarch @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build WORKDIR /src COPY . . -ARG TARGETOS TARGETARCH +ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ make build-cli diff --git a/docker/Dockerfile.cli.multiarch b/docker/Dockerfile.cli.multiarch index 4a28c64e6..9bdffb66d 100644 --- a/docker/Dockerfile.cli.multiarch +++ b/docker/Dockerfile.cli.multiarch @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build WORKDIR /src COPY . . -ARG TARGETOS TARGETARCH +ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ make build-cli