Cross-compile multi-platform images without QEMU
Publish Docker Image / Build and publish amd64 and arm64 (push) Successful in 1m30s
Publish Docker Image / Build and publish amd64 and arm64 (push) Successful in 1m30s
This commit is contained in:
1 parent
0c27c4bed1
commit
eedcb318f2
3 files changed
+25
-12
No files matched your search
+18
-5
@@ -1,18 +1,31 @@
|
||||
FROM golang:alpine AS builder
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
RUN apk add --update --no-cache --no-progress make git
|
||||
COPY go.mod go.sum ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY . /src
|
||||
|
||||
RUN apk add --update --no-cache --no-progress make git \
|
||||
&& make server
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
GOOS=$TARGETOS GOARCH=$TARGETARCH make server
|
||||
|
||||
# Certificates and timezone data are architecture-independent. Prepare them
|
||||
# natively so the target image needs no RUN instructions or QEMU emulation.
|
||||
FROM --platform=$BUILDPLATFORM alpine:latest AS runtime-data
|
||||
RUN apk add --update --no-cache --no-progress ca-certificates tzdata
|
||||
|
||||
FROM alpine:latest
|
||||
LABEL org.opencontainers.image.licenses=Apache-2.0
|
||||
LABEL org.opencontainers.image.source="https://gitea.bytevibe.dev/gary/metatube-server"
|
||||
|
||||
COPY --from=builder /src/build/metatube-server .
|
||||
|
||||
RUN apk add --update --no-cache --no-progress ca-certificates tzdata
|
||||
COPY --from=runtime-data /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=runtime-data /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
|
||||
ENV GIN_MODE=release
|
||||
ENV PORT=8080
|
||||
|
||||
Reference in new issue
Block a user