gopherss/Dockerfile

23 lines
700 B
Docker
Raw Normal View History

2020-10-17 19:57:26 +00:00
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.14-alpine as builder
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app/
2020-10-17 20:40:08 +00:00
RUN apk update && apk add --no-cache git gcc && adduser -D -g '' gopher && apk add -U --no-cache ca-certificates
2020-10-17 19:57:26 +00:00
ADD go.mod go.sum ./
RUN go mod download
ADD . .
2020-10-17 20:25:11 +00:00
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o gopherss .
2020-10-17 19:57:26 +00:00
FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
WORKDIR /app/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /app/gopherss /app/gopherss
2020-10-17 20:06:43 +00:00
COPY ./views /app/views/
2020-10-17 19:57:26 +00:00
USER gopher
ENTRYPOINT ["/app/gopherss"]