From b199bf10996b3fdf9d9c0b5bb6f5728e2b7ddbae Mon Sep 17 00:00:00 2001 From: greg pereira Date: Wed, 22 Nov 2023 07:00:02 -0800 Subject: [PATCH] chore: bump go version of base image to 1.21 --- Dockerfile | 11 ++++++----- Dockerfile.backfill-redis | 10 +++++++--- Dockerfile.cli | 8 +++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90f00366f..4a27fc0e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,18 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424dd30c38f652156040b490c9eca5ac5b61d8dc3ca AS builder +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder@sha256:98a0ff138c536eee98704d6909699ad5d0725a20573e2c510a60ef462b45cce0 AS build-env ENV APP_ROOT=/opt/app-root ENV GOPATH=$APP_ROOT WORKDIR $APP_ROOT/src/ ADD go.mod go.sum $APP_ROOT/src/ -RUN go mod download # Add source code ADD ./cmd/ $APP_ROOT/src/cmd/ ADD ./pkg/ $APP_ROOT/src/pkg/ +RUN go mod tidy && go mod vendor + ARG SERVER_LDFLAGS RUN go build -ldflags "${SERVER_LDFLAGS}" ./cmd/rekor-server RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "${SERVER_LDFLAGS}" -o rekor-server_debug ./cmd/rekor-server @@ -35,7 +36,7 @@ FROM registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424d RUN go install github.com/go-delve/delve/cmd/dlv@v1.8.0 # overwrite server and include debugger -COPY --from=builder /opt/app-root/src/rekor-server_debug /usr/local/bin/rekor-server +COPY --from=build-env /opt/app-root/src/rekor-server_debug /usr/local/bin/rekor-server FROM registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424dd30c38f652156040b490c9eca5ac5b61d8dc3ca as test @@ -53,7 +54,7 @@ RUN mkdir -p /var/run/attestations && \ chmod 777 /var/run/attestations/attestation.json # overwrite server with test build with code coverage -COPY --from=builder /opt/app-root/src/rekor-server_test /usr/local/bin/rekor-server +COPY --from=build-env /opt/app-root/src/rekor-server_test /usr/local/bin/rekor-server # Multi-Stage production build FROM registry.access.redhat.com/ubi9/ubi-minimal@sha256:7d1ea7ac0c6f464dac7bae6994f1658172bf6068229f40778a513bc90f47e624 as deploy @@ -66,7 +67,7 @@ LABEL summary="Provides the rekor Server binary for running Rekor-Server" LABEL com.redhat.component="rekor-server" # Retrieve the binary from the previous stage -COPY --from=builder /opt/app-root/src/rekor-server /usr/local/bin/rekor-server +COPY --from=build-env /opt/app-root/src/rekor-server /usr/local/bin/rekor-server # Set the binary as the entrypoint of the container ENTRYPOINT ["rekor-server"] \ No newline at end of file diff --git a/Dockerfile.backfill-redis b/Dockerfile.backfill-redis index 866cec6b4..7a075596c 100644 --- a/Dockerfile.backfill-redis +++ b/Dockerfile.backfill-redis @@ -1,9 +1,13 @@ #Build stage -FROM registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424dd30c38f652156040b490c9eca5ac5b61d8dc3ca AS build-env +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder@sha256:98a0ff138c536eee98704d6909699ad5d0725a20573e2c510a60ef462b45cce0 AS build-env USER root +ENV APP_ROOT=/opt/app-root + +WORKDIR $APP_ROOT/src/ + RUN git config --global --add safe.directory /opt/app-root/src -COPY . . -RUN make backfill-redis +ADD . . +RUN go mod tidy && go mod vendor && make backfill-redis #Install stage FROM registry.access.redhat.com/ubi9/ubi-minimal@sha256:7d1ea7ac0c6f464dac7bae6994f1658172bf6068229f40778a513bc90f47e624 diff --git a/Dockerfile.cli b/Dockerfile.cli index 0d0129429..9f6199777 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -1,12 +1,18 @@ #Build stage -FROM registry.access.redhat.com/ubi9/go-toolset@sha256:c3a9c5c7fb226f6efcec2424dd30c38f652156040b490c9eca5ac5b61d8dc3ca AS build-env +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder@sha256:98a0ff138c536eee98704d6909699ad5d0725a20573e2c510a60ef462b45cce0 AS build-env USER root + +RUN mkdir /opt/app-root && mkdir /opt/app-root/src + +WORKDIR /opt/app-root/src + RUN git config --global --add safe.directory /opt/app-root/src COPY . . RUN git stash && \ export GIT_VERSION=$(git describe --tags --always --dirty) && \ git stash pop && \ + go mod vendor && \ make Makefile.swagger && \ make -f Build.mak rekor-cli-darwin-amd64 && \ make -f Build.mak rekor-cli-linux-amd64 && \