This repository has been archived on 2022-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
morty/Dockerfile

36 lines
1.5 KiB
Docker

ARG ARCH
# STEP 1 build executable binary
FROM golang:1.16.7-alpine3.13@sha256:eba9c47f522b41337dbac394f18df4b040ba8bdb4e28e4ce0f504780d59acd86 AS builder-amd64
FROM arm32v7/golang:1.16.7-alpine3.13@sha256:1f52cd915cb844d697536be79c45f775daa5e3d954c23c0691938370670ed7dd AS builder-arm
FROM arm64v8/golang:1.16.7-alpine3.13@sha256:2ce14a0842a200c1edd14e9535f13b15ca03fd98b237d589f8ca971f10a411a3 AS builder-arm64
FROM builder-${ARCH} 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.14.1@sha256:be9bdc0ef8e96dbc428dc189b31e2e3b05523d96d12ed627c37aa2936653258c AS base-amd64
FROM arm32v7/alpine:3.14.1@sha256:fb9ac82b4cc94c5a6c416a1c656b3ee84df9290ab4106c260eb959997e759e5e AS base-arm
FROM arm64v8/alpine:3.14.1@sha256:bd9137c3bb45dbc40cde0f0e19a8b9064c2bc485466221f5e95eb72b0d0cf82e AS base-arm64
FROM base-${ARCH}
RUN apk upgrade --no-cache && \
apk --no-cache add ca-certificates="20191127-r5" && \
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"]