Open AlphaWong opened 6 years ago
# Start by building the application.
FROM golang:alpine as build
RUN apk add --no-cache git build-base && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk add --no-cache upx
# RUN apt-get update && apt-get install -y --no-install-recommends \
# upx
WORKDIR /go/src/git.easygroup.co/api-training-tools
COPY . .
RUN go get -u github.com/golang/dep/cmd/dep && dep ensure -v -vendor-only
RUN CGO_ENABLE=0 GOOS=linux go build \
-tags netgo \
-installsuffix netgo,cgo \
-v -a \
-ldflags '-s -w -extldflags "-static"' \
-o app
# RUN upx --best -qq app && upx -t app
# FROM gcr.io/distroless/base
FROM golang:alpine
WORKDIR /go/src/git.easygroup.co/api-training-tools
COPY --from=build /go/src/git.easygroup.co/api-training-tools .
ENTRYPOINT ["./app"]
EXPOSE 8080
# Start by building the application.
FROM golang:1 as build
RUN apt-get update && apt-get install -y --no-install-recommends upx
WORKDIR /go/src/git.easygroup.co/api-training-tools
COPY . .
RUN go get -u github.com/golang/dep/cmd/dep && dep ensure -v -vendor-only
RUN CGO_ENABLE=0 GOOS=linux go build \
-tags netgo \
-installsuffix netgo,cgo \
-v -a \
-ldflags '-s -w -extldflags "-static"' \
-o app
# RUN upx --best -qq app && upx -t app
# FROM gcr.io/distroless/base
FROM golang:alpine
WORKDIR /go/src/git.easygroup.co/api-training-tools
COPY --from=build /go/src/git.easygroup.co/api-training-tools .
ENTRYPOINT ["./app"]
EXPOSE 8080