28 lines
922 B
Docker
28 lines
922 B
Docker
# STEP 1 build executable binary
|
|
FROM golang:1.17.3-alpine3.13@sha256:33c95bc78fa434bae90c45d04e5a02612492acbb7118f35538a56ee0646c1bb7 AS builder
|
|
|
|
ENV MORTY_VERSION="f5bff1e285d3f973cacf73318e55175edafd633f"
|
|
|
|
WORKDIR $GOPATH/src/github.com/asciimoo/morty
|
|
|
|
RUN apk upgrade --no-cache && \
|
|
apk add --no-cache git && \
|
|
git clone https://github.com/asciimoo/morty.git . && \
|
|
git checkout "${MORTY_VERSION}"
|
|
|
|
RUN go get -d -v && gofmt -l ./ && go build .
|
|
|
|
# STEP 2 build the image including only the binary
|
|
FROM alpine:3.15.2@sha256:ceeae2849a425ef1a7e591d8288f1a58cdf1f4e8d9da7510e29ea829e61cf512
|
|
|
|
RUN apk upgrade --no-cache && \
|
|
apk --no-cache add ca-certificates && \
|
|
rm -f /var/cache/apk/* && \
|
|
adduser -D -h /usr/local/morty -s /bin/false morty morty
|
|
|
|
COPY --from=builder /go/src/github.com/asciimoo/morty/morty /usr/local/morty/morty
|
|
|
|
EXPOSE 3000
|
|
USER morty
|
|
|
|
ENTRYPOINT ["/usr/local/morty/morty"]
|