Skip to content

Instantly share code, notes, and snippets.

@mehmetcantas
Created July 22, 2021 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehmetcantas/5e4133b8a51587bdf0b9b1db7704fb3e to your computer and use it in GitHub Desktop.
Save mehmetcantas/5e4133b8a51587bdf0b9b1db7704fb3e to your computer and use it in GitHub Desktop.
FROM golang:1.16-alpine as builder
ARG CGO_ENABLED=0
RUN apk add --no-cache upx
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -ldflags "-s -w" -o main ./cmd/api
RUN upx --best --lzma main
FROM scratch
COPY --from=builder /app/main .
ENTRYPOINT ["./main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment