From 7b4bb1e36a9aea5d222db7f8cad09b0f95dfeea9 Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Sun, 6 Oct 2024 18:04:13 +0000 Subject: [PATCH] Multi-platform dockerfile --- Dockerfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 204e9e8..a223734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,17 @@ -FROM chimeralinux/chimera:latest AS base -RUN apk add go - -FROM base AS builder +FROM chimeralinux/chimera:latest as base +FROM base as builder WORKDIR /app +RUN apk add go COPY . . -RUN go build -ldflags "-s -w" -o diodemail -buildmode=pie ./cmd/server +ARG TARGETPLATFORM +RUN if [ $TARGETPLATFORM == "linux/riscv64" ]; then \ + apk add clang; \ + CGO_ENABLED=1 go build -ldflags="-s -w" -o diodemail -buildmode=pie ./cmd/server; \ +else \ + go build -ldflags="-s -w" -o diodemail -buildmode=pie ./cmd/server; \ +fi -FROM base AS runner +FROM base as runner WORKDIR /app COPY --from=builder /app/diodemail ./diodemail - CMD ["./diodemail"]