Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add multi-architecture support for Docker build #536

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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