Debian Codegraph @

Dockerfile

raw
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
15 FROM golang:1.26.3@sha256:2d6c80227255c3112a4d08e67ba98e58efd3846daf15d9d7d4c389565d881b1a AS builder
16 ENV APP_ROOT=/opt/app-root
17 ENV GOPATH=$APP_ROOT
18
19 WORKDIR $APP_ROOT/src/
20 ADD go.mod go.sum $APP_ROOT/src/
21 RUN go mod download
22
23 # Add source code
24 ADD ./cmd/ $APP_ROOT/src/cmd/
25 ADD ./pkg/ $APP_ROOT/src/pkg/
26
27 ARG SERVER_LDFLAGS
28 RUN go build -ldflags "${SERVER_LDFLAGS}" ./cmd/timestamp-server
29 RUN 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
32 FROM golang:1.26.3@sha256:2d6c80227255c3112a4d08e67ba98e58efd3846daf15d9d7d4c389565d881b1a AS deploy
33
34 # Retrieve the binary from the previous stage
35 COPY --from=builder /opt/app-root/src/timestamp-server /usr/local/bin/timestamp-server
36
37 # Set the binary as the entrypoint of the container
38 CMD ["timestamp-server", "serve"]
39
40 # debug compile options & debugger
41 FROM deploy AS debug
42 RUN go install github.com/go-delve/delve/cmd/[email protected]
43
44 # overwrite server and include debugger
45 COPY --from=builder /opt/app-root/src/timestamp-server_debug /usr/local/bin/timestamp-server