-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
25 lines (24 loc) · 883 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#build stage
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
ARG CGO_ENABLED=0
ARG GOOS=linux
ARG GOARCH=amd64
# comes from buildx, eg 'linux/amd64'
ARG TARGETPLATFORM
WORKDIR /go/src/raspi/
COPY . .
RUN apk add --no-cache git ca-certificates
# When using -o and building (possibly) multiple packages, the target for -o must be directory or else:
# go build: cannot write multiple packages to non-directory
RUN mkdir -p /go/bin/builds
RUN go get -d -v
RUN CGO_ENABLED=$CGO_ENABLED GOOS=$GOOS GOARCH=$(echo "${TARGETPLATFORM}" | cut -d/ -f2)\
go build -o /go/bin/builds -v ./...
#final stage
#FROM gcr.io/distroless/base
FROM scratch
COPY --from=builder /go/bin/builds /
COPY --from=builder /go/src/raspi/templates /templates
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
ENTRYPOINT ["/server"]
LABEL org.opencontainers.image.source https://github.com/Snurppa/go-server