2019-03-27 05:14:07 +01:00
|
|
|
FROM golang:1.12-alpine as builder
|
|
|
|
RUN apk update && \
|
|
|
|
apk add --no-cache git && \
|
|
|
|
apk add --no-cache upx=3.95-r1
|
|
|
|
|
2019-03-24 14:57:29 +01:00
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
2019-03-27 05:14:07 +01:00
|
|
|
|
2019-03-28 03:01:02 +01:00
|
|
|
RUN go get github.com/GeertJohan/go.rice/rice && \
|
|
|
|
go get github.com/pilu/fresh
|
|
|
|
|
2019-03-24 14:57:29 +01:00
|
|
|
ENV GO111MODULE=on
|
2019-03-28 03:01:02 +01:00
|
|
|
RUN go mod vendor
|
2019-03-28 05:37:39 +01:00
|
|
|
RUN rice -i ./serv embed-go && \
|
|
|
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o service && \
|
2019-03-27 05:14:07 +01:00
|
|
|
upx --ultra-brute -qq service && \
|
|
|
|
upx -t service
|
2019-03-24 14:57:29 +01:00
|
|
|
|
|
|
|
#second stage
|
|
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
2019-03-28 05:37:39 +01:00
|
|
|
|
2019-03-28 03:01:02 +01:00
|
|
|
RUN apk add --no-cache tzdata
|
2019-03-27 05:14:07 +01:00
|
|
|
|
2019-03-24 14:57:29 +01:00
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
2019-03-27 05:14:07 +01:00
|
|
|
COPY --from=builder /app/service .
|
2019-03-28 05:37:39 +01:00
|
|
|
COPY --from=builder /app/*.yml ./
|
2019-03-27 05:14:07 +01:00
|
|
|
|
|
|
|
RUN chmod +x /app/service
|
|
|
|
USER nobody
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
2019-03-24 14:57:29 +01:00
|
|
|
CMD ./service
|