Skip to content

Commit

Permalink
add Dockerfile.buildx
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed May 16, 2024
1 parent c31918b commit 0323c49
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
file: ./Dockerfile.buildx
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions Dockerfile.buildx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx

FROM --platform=$BUILDPLATFORM golang:latest AS builder
ARG TARGETPLATFORM
ARG CGO_ENABLED=0
COPY --from=xx / /
# warp go command. (automatically set GOOS,GOARCH... from TARGETPLATFORM)
RUN xx-go --wrap

COPY . /src/
WORKDIR /src
RUN go build -ldflags "-s -w -X main.version=$(git describe --tags --long --always)" -trimpath -o mosproxy

FROM --platform=${TARGETPLATFORM} alpine:latest
COPY --from=builder /src/mosproxy /usr/bin/

RUN apk add --no-cache ca-certificates \
&& mkdir /etc/mosproxy

WORKDIR /etc/mosproxy
VOLUME /etc/mosproxy
EXPOSE 53/udp 53/tcp
CMD /usr/bin/mosproxy route -c config.yaml

0 comments on commit 0323c49

Please sign in to comment.