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