diff options
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -1,18 +1,39 @@ # syntax=docker/dockerfile:1 -FROM golang:1.22.5-alpine3.20 AS builder +FROM --platform=$BUILDPLATFORM golang:1.22.5-alpine3.20 AS builder + +ARG TARGETARCH + +ARG TARGETOS + +ENV CGO_ENABLED 0 + +ENV GOOS linux + +RUN apk update --no-cache && apk add --no-cache tzdata ca-certificates WORKDIR /app COPY go.mod go.sum ./ + RUN go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -o /app/gorum +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /app/gorum + +FROM --platform=$BUILDPLATFORM scratch + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +COPY --from=builder /usr/share/zoneinfo/Europe/Moscow /usr/share/zoneinfo/Europe/Moscow + +ENV TZ Europe/Moscow + +WORKDIR /app -FROM alpine:3.20 +COPY --from=builder /app/gorum /app/gorum -COPY --from=builder /app/gorum . +EXPOSE 8000 -ENTRYPOINT ["/gorum"]
\ No newline at end of file +ENTRYPOINT ["/app/gorum"]
\ No newline at end of file |