diff --git a/Dockerfile b/Dockerfile index a87321127..864507e45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,8 @@ # Build the manager binary FROM docker.io/library/golang:1.21.6 as builder +ARG SOURCE_DATE_EPOCH + WORKDIR /workspace # Copy the Go Modules manifests COPY go.mod go.mod @@ -40,7 +42,10 @@ COPY version/ version/ COPY log/ log/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags=-buildid= -a -o manager main.go +# We force a timestamp to the output to guarantee a reproducible build, once we have BuildKit 0.12, this won't be needed anymore. +# The workaround to force the date format is because docker cli is expecting an int from this parameter (the timestamp). +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags=-buildid= -a -o manager main.go && \ + touch -d $(date '+%FT%H:%M:%S' -d @${SOURCE_DATE_EPOCH}) manager FROM registry.access.redhat.com/ubi9/ubi-micro:9.3-9 WORKDIR /usr/local/bin diff --git a/Makefile b/Makefile index 630814bdd..f8f4e43d7 100644 --- a/Makefile +++ b/Makefile @@ -162,11 +162,11 @@ debug: build-4-debug ## Run a controller from your host from binary .PHONY: docker-build docker-build: generate ## Build docker image with the manager. - docker build --build-arg SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) -t ${IMG} . + docker build --build-arg SOURCE_DATE_EPOCH="$(shell git log -1 --pretty=%ct)" -t ${IMG} . .PHONY: podman-build podman-build: generate ## Build container image with the manager. - podman build --build-arg SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) -t ${IMG} . + podman build --build-arg SOURCE_DATE_EPOCH="$(shell git log -1 --pretty=%ct)" -t ${IMG} . .PHONY: docker-push docker-push: ## Push docker image with the manager. @@ -186,7 +186,7 @@ docker-buildx: generate ## Build and push docker image for the manager for cross sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder docker buildx use project-v3-builder - - docker buildx build --build-arg SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross + - docker buildx build --build-arg SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=%ct) --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross - docker buildx rm project-v3-builder rm Dockerfile.cross diff --git a/api/v1alpha08/zz_generated.deepcopy.go b/api/v1alpha08/zz_generated.deepcopy.go index 0260a749c..51e02417f 100644 --- a/api/v1alpha08/zz_generated.deepcopy.go +++ b/api/v1alpha08/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ package v1alpha08 import ( "github.com/serverlessworkflow/sdk-go/v2/model" - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" diff --git a/api/zz_generated.deepcopy.go b/api/zz_generated.deepcopy.go index 4fd61d6d9..b68499c7b 100644 --- a/api/zz_generated.deepcopy.go +++ b/api/zz_generated.deepcopy.go @@ -20,6 +20,8 @@ package api +import () + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Condition) DeepCopyInto(out *Condition) { *out = *in diff --git a/container-builder/api/zz_generated.deepcopy.go b/container-builder/api/zz_generated.deepcopy.go index e19547bf4..46f2ddaea 100644 --- a/container-builder/api/zz_generated.deepcopy.go +++ b/container-builder/api/zz_generated.deepcopy.go @@ -21,7 +21,7 @@ package api import ( - v1 "k8s.io/api/core/v1" + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/modules/org.kie.kogito.app.builder/install.sh b/modules/org.kie.kogito.app.builder/install.sh index 33d4aac36..1f473b6fc 100644 --- a/modules/org.kie.kogito.app.builder/install.sh +++ b/modules/org.kie.kogito.app.builder/install.sh @@ -18,4 +18,4 @@ set -e cd /workspace -CGO_ENABLED=0 GO111MODULE=on go build -a -o manager main.go; \ No newline at end of file +CGO_ENABLED=0 GO111MODULE=on go build -trimpath -ldflags=-buildid= -a -o manager main.go; \ No newline at end of file diff --git a/modules/org.kie.kogito.osl.builder.prod/install.sh b/modules/org.kie.kogito.osl.builder.prod/install.sh index 90b64c312..f9e09bce7 100755 --- a/modules/org.kie.kogito.osl.builder.prod/install.sh +++ b/modules/org.kie.kogito.osl.builder.prod/install.sh @@ -18,5 +18,5 @@ set -e cd $REMOTE_SOURCE_DIR/app -source $CACHITO_ENV_FILE && go build -a -o manager main.go +source $CACHITO_ENV_FILE && go build -trimpath -ldflags=-buildid= -a -o manager main.go mkdir /workspace && cp $REMOTE_SOURCE_DIR/app/manager /workspace \ No newline at end of file