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

Commit

Permalink
add SOURCE_DATE_EPOCH to Dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
ferenc-hechler committed Jun 10, 2024
1 parent cbc5077 commit 386334d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ 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
with:
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
Expand All @@ -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 }}
13 changes: 11 additions & 2 deletions .github/workflows/build-prerelease-secretsmanagement-sidecar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 386334d

Please sign in to comment.