-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite dockerfile to use alpine (#8)
* Rewrite dockerfile to use alpine * use nproc instead of hardcoded 8 * remove redundant chown
- Loading branch information
Showing
1 changed file
with
11 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
FROM golang AS build | ||
FROM golang:alpine AS build | ||
|
||
WORKDIR /usr/gateway | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY . . | ||
RUN go build -o build/gateway | ||
# https://github.com/valyala/gozstd/issues/20 | ||
RUN apk add gcc musl-dev libc-dev make && \ | ||
GOZSTD_VER=$(cat go.mod | fgrep github.com/valyala/gozstd | awk '{print $NF}') && \ | ||
go get -d github.com/valyala/gozstd@${GOZSTD_VER} && \ | ||
cd ${GOPATH}/pkg/mod/github.com/valyala/gozstd@${GOZSTD_VER} && \ | ||
make clean && \ | ||
make -j $(nproc) libzstd.a && \ | ||
cd /usr/gateway && \ | ||
go build -o build/gateway | ||
|
||
FROM debian:buster-slim AS runtime | ||
RUN apt-get update -y && apt-get install -y ca-certificates | ||
FROM alpine:latest | ||
COPY --from=build /usr/gateway/build/gateway /gateway | ||
ENTRYPOINT ["/gateway"] |