Files
metatube-server/Dockerfile
T
gary eedcb318f2
Publish Docker Image / Build and publish amd64 and arm64 (push) Successful in 1m30s
Cross-compile multi-platform images without QEMU
2026-10-09 20:22:53 +08:00

43 lines
1.3 KiB
Docker

# 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
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 .
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
ENV TOKEN=""
ENV DSN=""
ENV REQUEST_TIMEOUT=""
ENV DB_MAX_IDLE_CONNS=0
ENV DB_MAX_OPEN_CONNS=0
ENV DB_PREPARED_STMT=0
ENV DB_AUTO_MIGRATE=0
EXPOSE 8080
ENTRYPOINT ["/metatube-server"]