Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
ci: Replace docker build args with secret mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad-ohms committed Sep 14, 2023
1 parent baac73b commit 7373e57
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ci/container-image-build-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ params:
CONTEXT: source/((flavor))
IMAGE_PLATFORM: ((target-platform)) # This param tells the `concourse-oci-build-task` task which architecture to build the image for.
BUILD_ARG_TARGETPLATFORM: ((target-platform)) # the instana-agent-docker Dockerfile requires a TARGETPLATFORM build arg.
BUILD_ARG_DOWNLOAD_KEY: ((agent-download-key)) # required by the instana-agent-docker Dockerfile
BUILDKIT_SECRETTEXT_DOWNLOAD_KEY: ((agent-download-key)) # required by the instana-agent-docker Dockerfile
BUILD_ARG_FLAVOR: ((flavor)) # required by the instana-agent-docker Dockerfile
BUILD_ARG_CLASSIFIER: ((classifier)) # required by the instana-agent-docker Dockerfile
BUILD_ARG_VERSION: ((version)) # required by the instana-agent-docker Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions dynamic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS instana-agent

ARG TARGETPLATFORM='linux/amd64'
ARG CLASSIFIER=''
ARG DOWNLOAD_KEY
# This is for backwards compatibility for end users that build their own images
ARG FTP_PROXY

RUN microdnf update && curl -sSL https://packages.instana.io/Instana.gpg -o /tmp/Instana.gpg && \
RUN --mount=type=secret,id=DOWNLOAD_KEY DOWNLOAD_KEY="$(cat /run/secrets/DOWNLOAD_KEY)" && \
microdnf update && curl -sSL https://packages.instana.io/Instana.gpg -o /tmp/Instana.gpg && \
rpm --import /tmp/Instana.gpg && \
export arch=$(case "${TARGETPLATFORM}" in 'linux/amd64') echo 'x86_64' ;; 'linux/arm64') echo 'aarch64' ;; 'linux/s390x') echo 's390x' ;; 'linux/ppc64le') echo 'ppc64le' ;; esac) && \
[[ -z "${FTP_PROXY}" ]] || DOWNLOAD_KEY="${FTP_PROXY}" && \
Expand Down
6 changes: 5 additions & 1 deletion dynamic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ features](https://github.com/docker/cli/blob/master/experimental/README.md) need
export TARGETPLATFORM=linux/s390x
export DOWNLOAD_KEY=my-key

echo "${DOWNLOAD_KEY}" > ${HOME}/.INSTANA_DOWNLOAD_KEY

docker buildx build --no-cache \
--build-arg DOWNLOAD_KEY="${DOWNLOAD_KEY}" \
--secret id=DOWNLOAD_KEY,src=${HOME}/.INSTANA_DOWNLOAD_KEY \
--platform="${TARGETPLATFORM}" \
--build-arg "TARGETPLATFORM=${TARGETPLATFORM}" \
-t instana/agent \
.

rm -f ${HOME}/.INSTANA_DOWNLOAD_KEY
```

Supported values of `<PLATFORM>`:
Expand Down
5 changes: 3 additions & 2 deletions static/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS instana-agent

ARG TARGETPLATFORM='linux/amd64'
ARG CLASSIFIER=''
ARG DOWNLOAD_KEY
# This is for backwards compatibility for end users that build their own images
ARG FTP_PROXY

RUN microdnf update && curl -sSL https://packages.instana.io/Instana.gpg -o /tmp/Instana.gpg && \
# Use secret mounts to prevent leakage of secrets in docker image metadata
RUN --mount=type=secret,id=DOWNLOAD_KEY DOWNLOAD_KEY="$(cat /run/secrets/DOWNLOAD_KEY)" && \
microdnf update && curl -sSL https://packages.instana.io/Instana.gpg -o /tmp/Instana.gpg && \
rpm --import /tmp/Instana.gpg && \
export arch=$(case "${TARGETPLATFORM}" in 'linux/amd64') echo 'x86_64' ;; 'linux/arm64') echo 'aarch64' ;; 'linux/s390x') echo 's390x' ;; 'linux/ppc64le') echo 'ppc64le' ;; esac) && \
[[ -z "${FTP_PROXY}" ]] || DOWNLOAD_KEY="${FTP_PROXY}" && \
Expand Down
6 changes: 5 additions & 1 deletion static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ features](https://github.com/docker/cli/blob/master/experimental/README.md) need
export TARGETPLATFORM=linux/s390x
export DOWNLOAD_KEY=my-key

echo "${DOWNLOAD_KEY}" > ${HOME}/.INSTANA_DOWNLOAD_KEY

docker buildx build --no-cache \
--build-arg DOWNLOAD_KEY="${DOWNLOAD_KEY}" \
--secret id=DOWNLOAD_KEY,src=${HOME}/.INSTANA_DOWNLOAD_KEY \
--platform="${TARGETPLATFORM}" \
--build-arg "TARGETPLATFORM=${TARGETPLATFORM}" \
-t containers.instana.io/instana/release/agent/static \
.

rm -f ~/.INSTANA_DOWNLOAD_KEY
```

Supported values of `<PLATFORM>`:
Expand Down

0 comments on commit 7373e57

Please sign in to comment.