...

Text file src/github.com/sigstore/rekor/Dockerfile

Documentation: github.com/sigstore/rekor

     1#
     2# Copyright 2021 The Sigstore Authors.
     3#
     4# Licensed under the Apache License, Version 2.0 (the "License");
     5# you may not use this file except in compliance with the License.
     6# You may obtain a copy of the License at
     7#
     8#     http://www.apache.org/licenses/LICENSE-2.0
     9#
    10# Unless required by applicable law or agreed to in writing, software
    11# distributed under the License is distributed on an "AS IS" BASIS,
    12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13# See the License for the specific language governing permissions and
    14# limitations under the License.
    15
    16FROM golang:1.21.8@sha256:c82d4ad02c062cf2b393bf0374df26638c6fed3dfe52cdbd3635d4a7befab86e AS builder
    17ENV APP_ROOT=/opt/app-root
    18ENV GOPATH=$APP_ROOT
    19
    20WORKDIR $APP_ROOT/src/
    21ADD go.mod go.sum $APP_ROOT/src/
    22RUN go mod download
    23
    24# Add source code
    25ADD ./cmd/ $APP_ROOT/src/cmd/
    26ADD ./pkg/ $APP_ROOT/src/pkg/
    27
    28ARG SERVER_LDFLAGS
    29RUN go build -ldflags "${SERVER_LDFLAGS}" ./cmd/rekor-server
    30RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -ldflags "${SERVER_LDFLAGS}" -o rekor-server_debug ./cmd/rekor-server
    31RUN go test -c -ldflags "${SERVER_LDFLAGS}" -cover -covermode=count -coverpkg=./... -o rekor-server_test ./cmd/rekor-server
    32
    33# Multi-Stage production build
    34FROM golang:1.21.8@sha256:c82d4ad02c062cf2b393bf0374df26638c6fed3dfe52cdbd3635d4a7befab86e as deploy
    35
    36# Retrieve the binary from the previous stage
    37COPY --from=builder /opt/app-root/src/rekor-server /usr/local/bin/rekor-server
    38
    39# Set the binary as the entrypoint of the container
    40CMD ["rekor-server", "serve"]
    41
    42# debug compile options & debugger
    43FROM deploy as debug
    44RUN go install github.com/go-delve/delve/cmd/dlv@v1.22.1
    45
    46# overwrite server and include debugger
    47COPY --from=builder /opt/app-root/src/rekor-server_debug /usr/local/bin/rekor-server
    48
    49FROM deploy as test
    50# overwrite server with test build with code coverage
    51COPY --from=builder /opt/app-root/src/rekor-server_test /usr/local/bin/rekor-server

View as plain text