-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathdockerfile
More file actions
30 lines (22 loc) · 813 Bytes
/
dockerfile
File metadata and controls
30 lines (22 loc) · 813 Bytes
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
# First stage: build the executable.
FROM golang:1.12 AS builder
# Set the working directory outside $GOPATH to enable the support for modules.
WORKDIR /src
# Fetch dependencies first; they are less susceptible to change on every build
# and will therefore be cached for speeding up the next build
COPY ./go.mod ./go.sum ./
RUN go mod download
# Import the code from the context.
COPY ./ ./
# Build the executable to `/app`. Mark the build as statically linked.
RUN CGO_ENABLED=0 go build \
-installsuffix 'static' \
-o /denti .
# Final stage: the running container.
FROM scratch AS final
# Import the compiled executable from the first stage.
COPY --from=builder /denti /denti
# Declare the port on which the webserver will be exposed.
EXPOSE 8080
# Run the compiled binary.
ENTRYPOINT ["/denti"]