Skip to content

Commit

Permalink
feat: add multi-architecture support for Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
realskyrin committed Feb 21, 2025
1 parent c1922cf commit 309e44b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docker/latest/Dockerfile.standalone
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
ARG VER_GOLANG=1.17.6-alpine3.15
ARG VER_ALPINE=3.15

FROM "doocs/md:latest-assets" AS assets
FROM --platform=$BUILDPLATFORM "doocs/md:latest-assets" AS assets

FROM "golang:$VER_GOLANG" AS gobuilder
FROM --platform=$BUILDPLATFORM "golang:$VER_GOLANG" AS gobuilder
ARG TARGETARCH
ARG TARGETOS
COPY --from=assets /app/* /app/assets/
COPY server/main.go /app
COPY docker/latest/server/main.go /app
RUN apk add git bash gcc musl-dev upx
WORKDIR /app
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH
RUN go build -ldflags "-w -s" -o md main.go && \
apk add upx && \
upx -9 -o md.minify md
if [ "$TARGETARCH" = "amd64" ]; then upx -9 -o md.minify md; else cp md md.minify; fi

FROM "alpine:$VER_ALPINE"
FROM --platform=$TARGETPLATFORM "alpine:$VER_ALPINE"
LABEL MAINTAINER="ylb<[email protected]>"
COPY --from=gobuilder /app/md.minify /bin/md
EXPOSE 80
Expand Down

0 comments on commit 309e44b

Please sign in to comment.