-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multi-architecture support for Docker build
- Loading branch information
1 parent
c1922cf
commit 309e44b
Showing
1 changed file
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|