diff --git a/Dockerfile.build b/Dockerfile.build index 72dc4a1d8..f1b4d1e73 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -25,12 +25,12 @@ FROM build AS build-bootstrapper WORKDIR /constellation/bootstrapper/ ARG PROJECT_VERSION -RUN go build -o bootstrapper -tags=disable_tpm_simulator -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/bootstrapper/ +RUN --mount=type=cache,target=/root/.cache/go-build go build -o bootstrapper -tags=disable_tpm_simulator -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/bootstrapper/ FROM build AS build-disk-mapper WORKDIR /constellation/disk-mapper/ -RUN go build -o disk-mapper -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ +RUN --mount=type=cache,target=/root/.cache/go-build go build -o disk-mapper -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ FROM scratch AS bootstrapper COPY --from=build-bootstrapper /constellation/bootstrapper/bootstrapper / diff --git a/access_manager/Dockerfile b/access_manager/Dockerfile index 10918d22a..4bced48ed 100644 --- a/access_manager/Dockerfile +++ b/access_manager/Dockerfile @@ -23,7 +23,7 @@ RUN rm -rf ./hack/ # Build the access_manager WORKDIR /constellation/access_manager/ -RUN CGO_ENABLED=0 go build -o /constellation/build/access_manager -ldflags "-s -w" . +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -o /constellation/build/access_manager -ldflags "-s -w" . # Copy the access_manager from build into a scratch container, which is eventually deployed into the cluster FROM scratch as release diff --git a/joinservice/Dockerfile b/joinservice/Dockerfile index cb38a5f48..1174e6579 100644 --- a/joinservice/Dockerfile +++ b/joinservice/Dockerfile @@ -23,7 +23,7 @@ RUN rm -rf ./hack/ WORKDIR /constellation/joinservice ARG PROJECT_VERSION=0.0.0 -RUN CGO_ENABLED=0 go build -o join-service -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -o join-service -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ # Use gcr.io/distroless/static here since we need CA certificates to be installed for aTLS operations on GCP. FROM gcr.io/distroless/static@sha256:ebd8cc37d22551dce0957ba8e58f03b22a8448bbf844c8c9ded4feef883b36bc as release diff --git a/kms/Dockerfile b/kms/Dockerfile index 21d1c8227..7245df0fe 100644 --- a/kms/Dockerfile +++ b/kms/Dockerfile @@ -24,7 +24,7 @@ RUN rm -rf ./hack/ RUN mkdir -p /constellation/build WORKDIR /constellation/kms/cmd ARG PROJECT_VERSION=0.0.0 -RUN CGO_ENABLED=0 go build -o /constellation/build/kmsserver -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -o /constellation/build/kmsserver -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" FROM gcr.io/distroless/static:nonroot@sha256:ed05c7a5d67d6beebeba19c6b9082a5513d5f9c3e22a883b9dc73ec39ba41c04 as release COPY --from=build /constellation/build/kmsserver /kmsserver diff --git a/verify/Dockerfile b/verify/Dockerfile index 24555a791..c916411db 100644 --- a/verify/Dockerfile +++ b/verify/Dockerfile @@ -23,7 +23,7 @@ RUN rm -rf ./hack/ WORKDIR /constellation/verify ARG PROJECT_VERSION=0.0.0 -RUN CGO_ENABLED=0 go build -o verify-service -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ +RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 go build -o verify-service -trimpath -buildvcs=false -ldflags "-s -w -buildid='' -X github.com/edgelesssys/constellation/v2/internal/constants.VersionInfo=${PROJECT_VERSION}" ./cmd/ FROM scratch AS release COPY --from=build /constellation/verify/verify-service /verify