-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (26 loc) · 853 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# build the webapp including dependencies from / and /cmd
# For information about the use of the gcr.io/distroless/static final
# container image, see the gcr.io docs at
# https://github.com/GoogleContainerTools/distroless/blob/main/base/README.md
FROM golang:1.22.5 AS deps
# setup module environment
WORKDIR /build
ADD go.mod go.sum ./
RUN go mod download
ADD cmd/web/*mod cmd/web/*sum ./cmd/web/
RUN cd /build/cmd/web && go mod download
# build
FROM deps as dev
ADD *go ./
ADD cmd/*go ./cmd/
ADD cmd/web/ ./cmd/web/
ADD location/ ./location/
RUN cd cmd/web && \
CGO_ENABLED=0 GOOS=linux \
go build -ldflags "-w -X main.docker=true" -o /build/webserver .
# install into minimal image
FROM gcr.io/distroless/base AS base
WORKDIR /
EXPOSE 8000
COPY --from=dev /build/webserver /
CMD ["/webserver", "--address", "0.0.0.0", "--port", "8000"]