8000 build: pass GIT_SHA into the image build, keep .git out of the context by Slach · Pull Request #2176 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git
dev/bin/
dev/log/
docs/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:

echo "${DOCKER_PASS}" | docker login -u $DOCKER_USER --password-stdin docker.io
echo "Building operator image with SBOM + provenance + metadata capture"
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file operator-build-metadata.json --pull --push .
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file operator-build-metadata.json --pull --push .
echo "Building metrics-exporter image with SBOM + provenance + metadata capture"
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file metrics-exporter-build-metadata.json --pull --push .
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file metrics-exporter-build-metadata.json --pull --push .
- name: Install syft (SBOM tool) if missing
run: |
set -euo pipefail
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:

echo "${DOCKER_PASS}" | docker login -u $DOCKER_USER --password-stdin docker.io
echo "Building operator image with SBOM + provenance + metadata capture"
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file operator-build-metadata.json --pull --push .
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/clickhouse-operator:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file operator-build-metadata.json --pull --push .
echo "Building metrics-exporter image with SBOM + provenance + metadata capture"
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file metrics-exporter-build-metadata.json --pull --push .
docker buildx build --progress plain --platform=linux/amd64,linux/arm64 -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} --build-arg GODEBUG_FIPS140=${GODEBUG_FIPS140} -t docker.io/${DOCKER_ORG}/metrics-exporter:${CHO_RELEASE} --sbom=true --provenance=mode=max --metadata-file metrics-exporter-build-metadata.json --pull --push .
- name: Install syft (SBOM tool) if missing
run: |
set -euo pipefail
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
export GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
export GOFIPS140=v1.0.0

docker build -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
docker build -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} -t altinity/metrics-exporter:${CHO_RELEASE} --pull .
docker build -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
docker build -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} -t altinity/metrics-exporter:${CHO_RELEASE} --pull .

docker image save altinity/clickhouse-operator:${CHO_RELEASE} -o operator.tar
docker image save altinity/metrics-exporter:${CHO_RELEASE} -o metrics-exporter.tar
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ jobs:
echo "current release=$CHO_RELEASE"
echo "current go version=$GO_VERSION"

docker build -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
docker build -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GOFIPS140=${GOFIPS140} -t altinity/metrics-exporter:${CHO_RELEASE} --pull .
docker build -f dockerfile/operator/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} -t altinity/clickhouse-operator:${CHO_RELEASE} --pull .
docker build -f dockerfile/metrics-exporter/Dockerfile --build-arg GO_VERSION=${GO_VERSION} --build-arg GIT_SHA=$(git rev-parse --short HEAD) --build-arg GOFIPS140=${GOFIPS140} -t altinity/metrics-exporter:${CHO_RELEASE} --pull .

docker image save altinity/clickhouse-operator:${CHO_RELEASE} -o operator.tar
docker image save altinity/metrics-exporter:${CHO_RELEASE} -o metrics-exporter.tar
Expand Down
4 changes: 2 additions & 2 deletions dev/go_build_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ REPO="github.com/altinity/clickhouse-operator"

# 0.9.3
VERSION=$(cd "${SRC_ROOT}" && cat release)
# 885c3f7
GIT_SHA=$(cd "${SRC_ROOT}" && git rev-parse --short HEAD)
# 885c3f7. The image build passes it in, because the build context has no .git
GIT_SHA="${GIT_SHA:-$(cd "${SRC_ROOT}" && git rev-parse --short HEAD)}"
# 2020-03-07 14:54:56
NOW=$(date "+%FT%T")
# Which version of golang to use. Ex.: 1.23.0
Expand Down
1 change: 1 addition & 0 deletions dev/image_build_universal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ fi

# Append VERSION and RELEASE
DOCKER_CMD="${DOCKER_CMD} --build-arg VERSION=${VERSION:-dev} --build-arg GO_VERSION=${GO_VERSION}"
DOCKER_CMD="${DOCKER_CMD} --build-arg GIT_SHA=${GIT_SHA}"

# Append GOFIPS140 build arg (sourced from go_build_config.sh, defaults to v1.0.0).
# Pass empty string explicitly to disable FIPS for non-FIPS-target images.
Expand Down
2 changes: 2 additions & 0 deletions dockerfile/metrics-exporter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ARG TARGETARCH
ARG BUILDARCH=amd64
ARG GCFLAGS
ARG GOFIPS140
ARG GIT_SHA

# Install required packages
RUN apt-get update && \
Expand All @@ -35,6 +36,7 @@ ENV GOOS="${TARGETOS}"
ENV GOARCH="${TARGETARCH}"
ENV GCFLAGS="${GCFLAGS}"
ENV GOFIPS140="${GOFIPS140}"
ENV GIT_SHA="${GIT_SHA}"

# Build operator binary with explicitly specified output
RUN METRICS_EXPORTER_BIN=/tmp/metrics-exporter bash -xe ./dev/go_build_metrics_exporter.sh
Expand Down
2 changes: 2 additions & 0 deletions dockerfile/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ARG TARGETARCH
ARG BUILDARCH=amd64
ARG GCFLAGS
ARG GOFIPS140
ARG GIT_SHA

# Install required packages
RUN apt-get update && \
Expand All @@ -35,6 +36,7 @@ ENV GOOS="${TARGETOS}"
ENV GOARCH="${TARGETARCH}"
ENV GCFLAGS="${GCFLAGS}"
ENV GOFIPS140="${GOFIPS140}"
ENV GIT_SHA="${GIT_SHA}"

# Build operator binary with explicitly specified output
RUN OPERATOR_BIN=/tmp/clickhouse-operator bash -xe ./dev/go_build_operator.sh
Expand Down
Loading
0