Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
Use proxy.golang.org to fetch dependencies faster/more reliably, produce
smaller upx-compressed binary.
  • Loading branch information
artyom committed Jun 12, 2019
1 parent e48064f commit 6414456
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM golang:latest as builder
RUN CGO_ENABLED=0 GOOS=linux go install -a -installsuffix=nocgo std
WORKDIR /project
COPY go.sum go.mod ./
FROM golang:alpine AS builder
RUN apk add --update upx
WORKDIR /app
ENV GOPROXY=https://proxy.golang.org CGO_ENABLED=0
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go test ./...
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -installsuffix=nocgo -o=/tmp/bitmapist-server
COPY . ./
RUN go build -ldflags='-s -w' -o bitmapist-server && upx --lzma bitmapist-server

FROM scratch
COPY --from=builder /tmp/bitmapist-server .
COPY --from=builder /app/bitmapist-server .
VOLUME /data
EXPOSE 6379
CMD ["./bitmapist-server", "-addr=:6379", "-db=/data/bitmapist.db", "-bak=/data/bitmapist.bak"]

0 comments on commit 6414456

Please sign in to comment.