From 386334d822b16d6db4197e93f4abf381d59b1b24 Mon Sep 17 00:00:00 2001 From: ferenc-hechler Date: Mon, 10 Jun 2024 21:54:24 +0200 Subject: [PATCH] add SOURCE_DATE_EPOCH to Dockerfile. --- .../build-prerelease-secretsmanagement-operator.yml | 6 +++--- .../build-prerelease-secretsmanagement-sidecar.yml | 13 +++++++++++-- .../secretsmanagementOperator-hc/docker/Dockerfile | 6 ++++-- .../docker/secretsmanagementOperatorHC.py | 12 ++++++------ .../sidecar/docker/Dockerfile | 6 ++++-- .../sidecar/docker/main.go | 3 ++- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-prerelease-secretsmanagement-operator.yml b/.github/workflows/build-prerelease-secretsmanagement-operator.yml index 2d4f886c..3e24bbd4 100644 --- a/.github/workflows/build-prerelease-secretsmanagement-operator.yml +++ b/.github/workflows/build-prerelease-secretsmanagement-operator.yml @@ -48,8 +48,8 @@ jobs: - name: Get Git commit timestamps run: | echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV - echo "CICD_BUILD_TIME=$(date -Iseconds)" >> $GITHUB_ENV echo "GIT_COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "CICD_BUILD_TIME=$(date -Iseconds)" >> $GITHUB_ENV - name: Build and push uses: docker/build-push-action@v5 @@ -57,8 +57,8 @@ jobs: context: source/operators/secretsmanagementOperator-hc/docker build-args: | SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH - CICD_BUILD_TIME=$CICD_BUILD_TIME GIT_COMMIT_SHA=$GIT_COMMIT_SHA + CICD_BUILD_TIME=$CICD_BUILD_TIME # arm64 has problems building cffi python wheel #platforms: linux/amd64,linux/arm64 platforms: linux/amd64 @@ -68,5 +68,5 @@ jobs: ${{ steps.get_smanop_image.outputs.result }}:${{ steps.get_smanop_version.outputs.result }} env: SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} - CICD_BUILD_TIME: ${{ env.CICD_BUILD_TIME }} GIT_COMMIT_SHA: ${{ env.GIT_COMMIT_SHA }} + CICD_BUILD_TIME: ${{ env.CICD_BUILD_TIME }} diff --git a/.github/workflows/build-prerelease-secretsmanagement-sidecar.yml b/.github/workflows/build-prerelease-secretsmanagement-sidecar.yml index 9baa2f41..dfc79366 100644 --- a/.github/workflows/build-prerelease-secretsmanagement-sidecar.yml +++ b/.github/workflows/build-prerelease-secretsmanagement-sidecar.yml @@ -46,16 +46,25 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Get Git commit timestamps - run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + run: | + echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + echo "GIT_COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "CICD_BUILD_TIME=$(date -Iseconds)" >> $GITHUB_ENV - name: Build and push uses: docker/build-push-action@v5 with: context: source/operators/secretsmanagementOperator-hc/sidecar/docker + build-args: | + SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH + GIT_COMMIT_SHA=$GIT_COMMIT_SHA + CICD_BUILD_TIME=$CICD_BUILD_TIME platforms: linux/amd64,linux/arm64 push: true tags: | ${{ steps.get_smansidecar_image.outputs.result }}:latest ${{ steps.get_smansidecar_image.outputs.result }}:${{ steps.get_smansidecar_version.outputs.result }} env: - SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} + SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} + GIT_COMMIT_SHA: ${{ env.GIT_COMMIT_SHA }} + CICD_BUILD_TIME: ${{ env.CICD_BUILD_TIME }} diff --git a/source/operators/secretsmanagementOperator-hc/docker/Dockerfile b/source/operators/secretsmanagementOperator-hc/docker/Dockerfile index ea5c4aa9..caa3a814 100644 --- a/source/operators/secretsmanagementOperator-hc/docker/Dockerfile +++ b/source/operators/secretsmanagementOperator-hc/docker/Dockerfile @@ -15,9 +15,11 @@ RUN pip install -r requirements.txt && \ ADD *.py /src/ -ARG CICD_BUILD_TIME -ENV CICD_BUILD_TIME $CICD_BUILD_TIME +ARG SOURCE_DATE_EPOCH +ENV SOURCE_DATE_EPOCH $SOURCE_DATE_EPOCH ARG GIT_COMMIT_SHA ENV GIT_COMMIT_SHA $GIT_COMMIT_SHA +ARG CICD_BUILD_TIME +ENV CICD_BUILD_TIME $CICD_BUILD_TIME CMD kopf run --all-namespaces --verbose /src/secretsmanagementOperatorHC.py diff --git a/source/operators/secretsmanagementOperator-hc/docker/secretsmanagementOperatorHC.py b/source/operators/secretsmanagementOperator-hc/docker/secretsmanagementOperatorHC.py index 2fb486e8..17e3684c 100644 --- a/source/operators/secretsmanagementOperator-hc/docker/secretsmanagementOperatorHC.py +++ b/source/operators/secretsmanagementOperator-hc/docker/secretsmanagementOperatorHC.py @@ -38,15 +38,15 @@ logger.info(f"Logging set to %s", logging_level) logger.debug(f"debug logging active") -CICD_BUILD_TIME = os.getenv("CICD_BUILD_TIME") -GIT_COMMIT_SHA = os.getenv("GIT_COMMIT_SHA") SOURCE_DATE_EPOCH = os.getenv("SOURCE_DATE_EPOCH") -if CICD_BUILD_TIME: - logger.info(f"CICD_BUILD_TIME=%s", CICD_BUILD_TIME) +GIT_COMMIT_SHA = os.getenv("GIT_COMMIT_SHA") +CICD_BUILD_TIME = os.getenv("CICD_BUILD_TIME") +if SOURCE_DATE_EPOCH: + logger.info(f"SOURCE_DATE_EPOCH=%s", SOURCE_DATE_EPOCH) if GIT_COMMIT_SHA: logger.info(f"GIT_COMMIT_SHA=%s", GIT_COMMIT_SHA) -if SOURCE_DATE_EPOCH: - logger.info(f"CICD_BUILD_TIME=%s", SOURCE_DATE_EPOCH) +if CICD_BUILD_TIME: + logger.info(f"CICD_BUILD_TIME=%s", CICD_BUILD_TIME) # vault_addr = os.getenv('VAULT_ADDR', 'https://canvas-vault-hc.ihc-dt.cluster-3.de') # vault_addr = os.getenv('VAULT_ADDR', 'https://canvas-vault-hc.k8s.cluster-1.de') diff --git a/source/operators/secretsmanagementOperator-hc/sidecar/docker/Dockerfile b/source/operators/secretsmanagementOperator-hc/sidecar/docker/Dockerfile index 2b2a560c..c3ff5ab9 100644 --- a/source/operators/secretsmanagementOperator-hc/sidecar/docker/Dockerfile +++ b/source/operators/secretsmanagementOperator-hc/sidecar/docker/Dockerfile @@ -17,9 +17,11 @@ COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /go/src/component-vault-service ./ EXPOSE 5000/tcp -ARG CICD_BUILD_TIME -ENV CICD_BUILD_TIME $CICD_BUILD_TIME +ARG SOURCE_DATE_EPOCH +ENV SOURCE_DATE_EPOCH $SOURCE_DATE_EPOCH ARG GIT_COMMIT_SHA ENV GIT_COMMIT_SHA $GIT_COMMIT_SHA +ARG CICD_BUILD_TIME +ENV CICD_BUILD_TIME $CICD_BUILD_TIME ENTRYPOINT ["./component-vault-service"] diff --git a/source/operators/secretsmanagementOperator-hc/sidecar/docker/main.go b/source/operators/secretsmanagementOperator-hc/sidecar/docker/main.go index 35bf6c68..98deea7f 100644 --- a/source/operators/secretsmanagementOperator-hc/sidecar/docker/main.go +++ b/source/operators/secretsmanagementOperator-hc/sidecar/docker/main.go @@ -24,8 +24,9 @@ import ( ) func main() { - fmt.Println("CICD_BUILD_TIME: ", getEnvVar("CICD_BUILD_TIME", "?")) + fmt.Println("SOURCE_DATE_EPOCH: ", getEnvVar("SOURCE_DATE_EPOCH", "?")) fmt.Println("GIT_COMMIT_SHA: ", getEnvVar("GIT_COMMIT_SHA", "?")) + fmt.Println("CICD_BUILD_TIME: ", getEnvVar("CICD_BUILD_TIME", "?")) init_vault()