Multi-platform dockerfile

This commit is contained in:
Gnarwhal 2024-10-06 18:04:13 +00:00
parent 51a1117950
commit 7b4bb1e36a
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174

View file

@ -1,13 +1,17 @@
FROM chimeralinux/chimera:latest AS base FROM chimeralinux/chimera:latest as base
RUN apk add go FROM base as builder
FROM base AS builder
WORKDIR /app WORKDIR /app
RUN apk add go
COPY . . 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 WORKDIR /app
COPY --from=builder /app/diodemail ./diodemail COPY --from=builder /app/diodemail ./diodemail
CMD ["./diodemail"] CMD ["./diodemail"]