-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
32 lines (23 loc) · 824 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
32
FROM golang:1.18-alpine as BUILDER
RUN apk update && apk add --no-cache git
WORKDIR /src
# << bake dependencies into image
COPY go.mod .
COPY go.sum .
RUN go mod download
# >>
# bring source into image
COPY . .
# build
RUN GIT_VERSION="$(git describe HEAD --always --tags)$( [[ -z "$(git status -s)" ]] || echo '+')" && \
CGO_ENABLED=0 go build -ldflags "-X main.serverVersion=${GIT_VERSION}" -o /go/bin/server github.com/rspier/rt-static/cmd/server
RUN touch /.empty
FROM scratch
WORKDIR /
COPY --from=builder /src/web/templates/ /web/templates/
COPY --from=builder /src/web/static/ /web/static/
COPY --from=builder /go/bin/server /server.bin
# If we don't put something in the /tmp/ directory, it doesn't exist,
# since this is FROM scratch.
COPY --from=builder /.empty /tmp/.empty
ENTRYPOINT ["/server.bin"]