mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 23:57:26 +08:00
chore: update workflows docker
This commit is contained in:
parent
a563e9375e
commit
a2aa267e43
65
.github/workflows/docker.yaml
vendored
65
.github/workflows/docker.yaml
vendored
@ -1,65 +0,0 @@
|
|||||||
name: Docker
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
paths-ignore:
|
|
||||||
- 'docs/**'
|
|
||||||
- 'README.md'
|
|
||||||
branches:
|
|
||||||
- Beta
|
|
||||||
- Alpha
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
env:
|
|
||||||
REGISTRY: docker.io
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
|
|
||||||
# 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 }}/${{ secrets.DOCKERHUB_ACCOUNT }}/${{secrets.DOCKERHUB_REPO}}
|
|
||||||
|
|
||||||
- name: Log into registry
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.DOCKER_HUB_USER }}
|
|
||||||
password: ${{ secrets.DOCKER_HUB_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: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
platforms: |
|
|
||||||
linux/386
|
|
||||||
linux/amd64
|
|
||||||
linux/arm64/v8
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
126
.github/workflows/prerelease.yml
vendored
126
.github/workflows/prerelease.yml
vendored
@ -3,8 +3,8 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- "docs/**"
|
||||||
- 'README.md'
|
- "README.md"
|
||||||
branches:
|
branches:
|
||||||
- Alpha
|
- Alpha
|
||||||
- Beta
|
- Beta
|
||||||
@ -12,6 +12,8 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- Alpha
|
- Alpha
|
||||||
- Beta
|
- Beta
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.io
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Build:
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
@ -20,18 +22,54 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
job:
|
job:
|
||||||
- { type: "WithoutCGO", target: "linux-amd64 linux-amd64-compatible", id: "1" }
|
- {
|
||||||
- { type: "WithoutCGO", target: "linux-armv5 linux-armv6 linux-armv7", id: "2" }
|
type: "WithoutCGO",
|
||||||
- { type: "WithoutCGO", target: "linux-arm64 linux-mips64 linux-mips64le", id: "3" }
|
target: "linux-amd64 linux-amd64-compatible",
|
||||||
- { type: "WithoutCGO", target: "linux-mips-softfloat linux-mips-hardfloat linux-mipsle-softfloat linux-mipsle-hardfloat", id: "4" }
|
id: "1",
|
||||||
- { type: "WithoutCGO", target: "freebsd-386 freebsd-amd64 freebsd-arm64", id: "5" }
|
}
|
||||||
- { type: "WithoutCGO", target: "windows-amd64-compatible windows-amd64 windows-386", id: "6" }
|
- {
|
||||||
- { type: "WithoutCGO", target: "windows-arm64 windows-arm32v7", id: "7" }
|
type: "WithoutCGO",
|
||||||
- { type: "WithoutCGO", target: "darwin-amd64 darwin-arm64 android-arm64", id: "8" }
|
target: "linux-armv5 linux-armv6 linux-armv7",
|
||||||
|
id: "2",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "linux-arm64 linux-mips64 linux-mips64le",
|
||||||
|
id: "3",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "linux-mips-softfloat linux-mips-hardfloat linux-mipsle-softfloat linux-mipsle-hardfloat",
|
||||||
|
id: "4",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "freebsd-386 freebsd-amd64 freebsd-arm64",
|
||||||
|
id: "5",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "windows-amd64-compatible windows-amd64 windows-386",
|
||||||
|
id: "6",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "windows-arm64 windows-arm32v7",
|
||||||
|
id: "7",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
type: "WithoutCGO",
|
||||||
|
target: "darwin-amd64 darwin-arm64 android-arm64",
|
||||||
|
id: "8",
|
||||||
|
}
|
||||||
- { type: "WithCGO", target: "windows/*", id: "1" }
|
- { type: "WithCGO", target: "windows/*", id: "1" }
|
||||||
- { type: "WithCGO", target: "linux/386,linux/amd64", id: "2" }
|
- { type: "WithCGO", target: "linux/386,linux/amd64", id: "2" }
|
||||||
- { type: "WithCGO", target: "linux/arm64,linux/riscv64", id: "3" }
|
- { type: "WithCGO", target: "linux/arm64,linux/riscv64", id: "3" }
|
||||||
- { type: "WithCGO", target: "linux/arm,linux/arm-6,linux/arm-7", id: "4" }
|
- {
|
||||||
|
type: "WithCGO",
|
||||||
|
target: "linux/arm,linux/arm-6,linux/arm-7",
|
||||||
|
id: "4",
|
||||||
|
}
|
||||||
- { type: "WithCGO", target: "linux/mips,linux/mipsle", id: "5" }
|
- { type: "WithCGO", target: "linux/mips,linux/mipsle", id: "5" }
|
||||||
- { type: "WithCGO", target: "linux/mips64,linux/mips64le", id: "6" }
|
- { type: "WithCGO", target: "linux/mips64,linux/mips64le", id: "6" }
|
||||||
- { type: "WithCGO", target: "darwin-10.16/*", id: "7" }
|
- { type: "WithCGO", target: "darwin-10.16/*", id: "7" }
|
||||||
@ -77,7 +115,7 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.19'
|
go-version: "1.19"
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
@ -152,10 +190,9 @@ jobs:
|
|||||||
name: artifact
|
name: artifact
|
||||||
path: bin/
|
path: bin/
|
||||||
|
|
||||||
|
|
||||||
Upload:
|
Upload:
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
needs: [ Build ]
|
needs: [Build]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
@ -190,3 +227,64 @@ jobs:
|
|||||||
files: bin/*
|
files: bin/*
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
Docker:
|
||||||
|
permissions: write-all
|
||||||
|
needs: [Build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
path: bin/
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
working-directory: bin
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Setup Docker buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
# 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 }}/${{ secrets.DOCKERHUB_ACCOUNT }}/${{secrets.DOCKERHUB_REPO}}
|
||||||
|
- name: Show files
|
||||||
|
run: |
|
||||||
|
ls .
|
||||||
|
ls bin/
|
||||||
|
- name: Log into registry
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_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: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
platforms: |
|
||||||
|
linux/386
|
||||||
|
linux/amd64
|
||||||
|
linux/arm64/v8
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
19
Dockerfile
19
Dockerfile
@ -1,18 +1,17 @@
|
|||||||
FROM golang:alpine as builder
|
FROM alpine:latest as builder
|
||||||
|
|
||||||
RUN apk add --no-cache make git && \
|
RUN apk add --no-cache gzip && \
|
||||||
mkdir /clash-config && \
|
mkdir /clash-config && \
|
||||||
wget -O /clash-config/Country.mmdb https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb && \
|
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/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 /clash-config/geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
||||||
|
|
||||||
|
COPY docker/file-name.sh /clash/file-name.sh
|
||||||
COPY . /clash-src
|
WORKDIR /clash
|
||||||
WORKDIR /clash-src
|
COPY bin/ bin/
|
||||||
RUN go mod download &&\
|
RUN FILE_NAME=`sh file-name.sh` && echo $FILE_NAME && \
|
||||||
make docker &&\
|
FILE_NAME=`ls bin/ | egrep "$FILE_NAME.*"|awk NR==1` && \
|
||||||
mv ./bin/clash.meta-docker /clash
|
mv bin/$FILE_NAME clash.gz && gzip -d clash.gz && echo "$FILE_NAME" > /clash-config/test
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
LABEL org.opencontainers.image.source="https://github.com/MetaCubeX/Clash.Meta"
|
LABEL org.opencontainers.image.source="https://github.com/MetaCubeX/Clash.Meta"
|
||||||
|
|
||||||
@ -21,6 +20,6 @@ RUN apk add --no-cache ca-certificates tzdata iptables
|
|||||||
VOLUME ["/root/.config/clash/"]
|
VOLUME ["/root/.config/clash/"]
|
||||||
|
|
||||||
COPY --from=builder /clash-config/ /root/.config/clash/
|
COPY --from=builder /clash-config/ /root/.config/clash/
|
||||||
COPY --from=builder /clash /clash
|
COPY --from=builder /clash/clash /clash
|
||||||
RUN chmod +x /clash
|
RUN chmod +x /clash
|
||||||
ENTRYPOINT [ "/clash" ]
|
ENTRYPOINT [ "/clash" ]
|
||||||
|
26
docker/file-name.sh
Normal file
26
docker/file-name.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
os="clash.meta-linux-"
|
||||||
|
arch=`uname -m`
|
||||||
|
case $arch in
|
||||||
|
"x86_64")
|
||||||
|
arch="amd64-compatible"
|
||||||
|
;;
|
||||||
|
"x86")
|
||||||
|
arch="386-cgo"
|
||||||
|
;;
|
||||||
|
"aarch64")
|
||||||
|
arch="arm64"
|
||||||
|
;;
|
||||||
|
"armv7l")
|
||||||
|
arch="armv7"
|
||||||
|
;;
|
||||||
|
"riscv64")
|
||||||
|
arch="riscv64-cgo"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown architecture"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
file_name="$os$arch"
|
||||||
|
echo $file_name
|
Loading…
Reference in New Issue
Block a user