diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 8eeb3c7d..00000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: Docker - -on: - push: - tags: [ 'v*.*.*' ] - workflow_dispatch: - -env: - REGISTRY: docker.io - IMAGE_NAME: '{{ env.DOCKERHUB_ACCOUNT }}/{{ env.DOCKERHUB_REPO }}' - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Setup Docker buildx - uses: docker/setup-buildx-action@v1 - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - platforms: | - linux/386 - linux/amd64 - linux/arm64/v8 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 498fbd44..6e67d5d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,41 +1,18 @@ FROM golang:alpine as builder -ARG TARGETOS -ARG TARGETARCH - RUN apk add --no-cache make git && \ - mkdir /clash-config && \ - wget -O /clash-config/Country.mmdb https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb && \ - wget -O /clash-config/geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat && \ - wget -O /clash-config/geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat - + wget -O /Country.mmdb https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb WORKDIR /clash-src +COPY --from=tonistiigi/xx:golang / / COPY . /clash-src -RUN go mod download -RUN /bin/ash -c 'set -ex && \ - if [ "$TARGETARCH" == "amd64" ]; then \ - GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v1 make docker && \ - mv ./bin/Clash.Meta-docker ./bin/clash-amd64v1 && \ - GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v2 make docker && \ - mv ./bin/Clash.Meta-docker ./bin/clash-amd64v2 && \ - GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v3 make docker && \ - mv ./bin/Clash.Meta-docker ./bin/clash-amd64v3 && \ - ln -s clash-amd64v3 ./bin/clash-amd64v4 && \ - mv check_amd64.sh ./bin/ && \ - printf "#!/bin/sh\\nsh ./check_amd64.sh\\nexec ./clash-amd64v\$? \$@" > ./bin/clash && \ - chmod +x ./bin/check_amd64.sh ./bin/clash; \ - else \ - GOOS=$TARGETOS GOARCH=$TARGETARCH make docker && \ - mv ./bin/Clash.Meta-docker ./bin/clash; \ - fi' +RUN go mod download && \ + make docker && \ + mv ./bin/clash-docker /clash + FROM alpine:latest -LABEL org.opencontainers.image.source="https://github.com/MetaCubeX/Clash.Meta" +LABEL org.opencontainers.image.source="https://github.com/Dreamacro/clash" RUN apk add --no-cache ca-certificates tzdata - -VOLUME ["/root/.config/clash/"] -EXPOSE 7890/tcp - -COPY --from=builder /clash-config/ /root/.config/clash/ -COPY --from=builder /clash-src/bin/ / -ENTRYPOINT [ "/clash" ] \ No newline at end of file +COPY --from=builder /Country.mmdb /root/.config/clash/ +COPY --from=builder /clash / +ENTRYPOINT ["/clash"] diff --git a/check_amd64.sh b/check_amd64.sh deleted file mode 100644 index 068296d3..00000000 --- a/check_amd64.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -flags=$(grep '^flags\b'