Skip to content

Commit

Permalink
Dockerfile: use multiple stage build to reduce image size
Browse files Browse the repository at this point in the history
Fix: DyegoCosta#17
Signed-off-by: CooperLi <[email protected]>
  • Loading branch information
CooperLi committed Aug 23, 2021
1 parent bad55ee commit ba4c059
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM golang:alpine
FROM golang:alpine as builder
ENV LANG en_US.UTF-8

COPY . /go/src/github.com/dyegocosta/snake-game
WORKDIR /go/src/github.com/dyegocosta/snake-game
COPY . .

RUN apk add --no-cache git
RUN go get ./
RUN go build -o ./_bin/snake-game
RUN go build -ldflags="-extldflags=-static" -o /go/bin/snake-game

ENTRYPOINT "./_bin/snake-game"
FROM scratch
WORKDIR /
COPY --from=builder /go/bin/snake-game .

ENTRYPOINT ["./snake-game"]

0 comments on commit ba4c059

Please sign in to comment.