36 lines
1.5 KiB
Docker
36 lines
1.5 KiB
Docker
ARG ARCH
|
|
|
|
# STEP 1 build executable binary
|
|
FROM amd64/golang:1.15.7-alpine3.12@sha256:9f88dc7df11a83b9641d71b4be4f8ccbfb2342e5cb733661363ed3d0a98fe3ef AS builder-amd64
|
|
FROM arm32v7/golang:1.15.7-alpine3.12@sha256:d54bff25a171d1b3036bf6b5dea2bbfaf75b7518e9b780a046750d8e26a19253 AS builder-arm
|
|
FROM arm64v8/golang:1.15.7-alpine3.12@sha256:e5389316a6dc295d6c0ca269c39124ad5bc9ebb416c71c810822cf6fbcf8ff01 AS builder-arm64
|
|
FROM builder-${ARCH} AS builder
|
|
|
|
ENV MORTY_VERSION="4021e4369d6f62690474991a9b6901b751b940d5"
|
|
|
|
WORKDIR $GOPATH/src/github.com/asciimoo/morty
|
|
|
|
RUN apk update && apk upgrade && \
|
|
apk add --no-cache git="2.26.2-r0" && \
|
|
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 amd64/alpine:3.12.3@sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7 AS base-amd64
|
|
FROM arm32v7/alpine:3.12.3@sha256:299294be8699c1b323c137f972fd0aa5eaa4b95489c213091dcf46ef39b6c810 AS base-arm
|
|
FROM arm64v8/alpine:3.12.3@sha256:549694ea68340c26d1d85c00039aa11ad835be279bfd475ff4284b705f92c24e AS base-arm64
|
|
FROM base-${ARCH}
|
|
|
|
RUN apk update && apk upgrade && \
|
|
apk --no-cache add ca-certificates="20191127-r4" && \
|
|
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"]
|