From 0abe62d6043f60b87218f86c941c3869150c73a4 Mon Sep 17 00:00:00 2001 From: Markson Hon Date: Sun, 12 Nov 2023 19:09:11 +0800 Subject: [PATCH] ci(release_main.yml): add Docker workflows ci(docker*.yml): remove stable single docker ci workflows --- .github/workflows/dockerimage_gui.yml | 34 -------- .github/workflows/release_main.yml | 118 +++++++++++++++++--------- install/docker/Dockerfile.Action | 10 ++- install/docker/Dockerfile.GUI.Action | 4 + install/docker/docker_helper.sh | 35 ++++++++ 5 files changed, 121 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/dockerimage_gui.yml create mode 100644 install/docker/Dockerfile.GUI.Action create mode 100644 install/docker/docker_helper.sh diff --git a/.github/workflows/dockerimage_gui.yml b/.github/workflows/dockerimage_gui.yml deleted file mode 100644 index 44226f8316..0000000000 --- a/.github/workflows/dockerimage_gui.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: v2raya_gui-docker - -on: - push: - tags: - - v* - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build production image - uses: docker/build-push-action@v2 - with: - context: . - builder: ${{ steps.buildx.outputs.name }} - file: Dockerfile.gui - platforms: linux/arm,linux/arm64,linux/amd64 - push: true - tags: mzz2017/v2raya-gui:latest - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/release_main.yml b/.github/workflows/release_main.yml index 3b8b37da31..fd4d1653ce 100644 --- a/.github/workflows/release_main.yml +++ b/.github/workflows/release_main.yml @@ -426,26 +426,26 @@ jobs: tag_name: v${{ steps.prep.outputs.VERSION }} files: | release/* - - name: Refresh Cloudflare Cache - env: - CF_AUTH_EMAIL: ${{ secrets.CF_AUTH_EMAIL }} - CF_PARGE_CACHE_AUTH_KEY: ${{ secrets.CF_PARGE_CACHE_AUTH_KEY }} - CF_ZONE: ${{ secrets.CF_ZONE }} - shell: bash - run: | - curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE/purge_cache" \ - -H "X-Auth-Email: $CF_AUTH_EMAIL" \ - -H "Authorization: Bearer $CF_PARGE_CACHE_AUTH_KEY" \ - -H "Content-Type: application/json" \ - --data '{"purge_everything":true}' - - name: Submit to Microsoft winget - shell: pwsh - run: | - iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - Start-Sleep -Seconds 30 #Make sure GitHub releases are online - $Installer_x64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_x64_${{ steps.prep.outputs.VERSION }}.exe" - $Installer_ARM64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_arm64_${{ steps.prep.outputs.VERSION }}.exe" - ./wingetcreate.exe update v2rayA.v2rayA --urls $Installer_x64_url $Installer_ARM64_url --version ${{ steps.prep.outputs.VERSION }} --token ${{ secrets.HOMEBREW_V2RAYA_TOKEN }} --submit + # - name: Refresh Cloudflare Cache + # env: + # CF_AUTH_EMAIL: ${{ secrets.CF_AUTH_EMAIL }} + # CF_PARGE_CACHE_AUTH_KEY: ${{ secrets.CF_PARGE_CACHE_AUTH_KEY }} + # CF_ZONE: ${{ secrets.CF_ZONE }} + # shell: bash + # run: | + # curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE/purge_cache" \ + # -H "X-Auth-Email: $CF_AUTH_EMAIL" \ + # -H "Authorization: Bearer $CF_PARGE_CACHE_AUTH_KEY" \ + # -H "Content-Type: application/json" \ + # --data '{"purge_everything":true}' + # - name: Submit to Microsoft winget + # shell: pwsh + # run: | + # iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe + # Start-Sleep -Seconds 30 #Make sure GitHub releases are online + # $Installer_x64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_x64_${{ steps.prep.outputs.VERSION }}.exe" + # $Installer_ARM64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_arm64_${{ steps.prep.outputs.VERSION }}.exe" + # ./wingetcreate.exe update v2rayA.v2rayA --urls $Installer_x64_url $Installer_ARM64_url --version ${{ steps.prep.outputs.VERSION }} --token ${{ secrets.HOMEBREW_V2RAYA_TOKEN }} --submit Build_v2ray_Debian_Packages: runs-on: ubuntu-22.04 if: startsWith(github.ref, 'refs/tags/v') @@ -714,9 +714,9 @@ jobs: v2raya-x86_64-linux.zip v2raya-x86_64-linux.zip.sha256.txt \ v2raya-x86_64-macos.zip v2raya-x86_64-macos.zip.sha256.txt \ v2raya-aarch64-macos.zip v2raya-aarch64-macos.zip.sha256.txt - Release_to_Docker: + Release_v2rayA_to_Docker: runs-on: ubuntu-22.04 - needs: [Build_v2rayA_Binaries] + needs: [GitHub_Release] if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v3 @@ -725,7 +725,6 @@ jobs: - name: Check Version id: prep run: | - echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT tag=$(git describe --tags $(git rev-list --tags --max-count=1)) version=${tag:1} echo "VERSION=$version" >> $GITHUB_OUTPUT @@ -733,22 +732,53 @@ jobs: TAG=$(echo $GITHUB_REF | cut -d / -f 3) IMAGE="mzz2017/v2raya" echo image=${IMAGE} >> $GITHUB_OUTPUT - echo tag=${TAG:1} >> $GITHUB_OUTPUT - - name: Download Artifact Linux x64 - uses: actions/download-artifact@v3 + echo tag=${TAG} >> $GITHUB_OUTPUT + sed -i "s|Realv2rayAVersion|$version|g" install/docker/docker_helper.sh + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.0.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.0.0 + - name: Login to DockerHub + uses: docker/login-action@v3.0.0 with: - name: v2raya_linux_x64_${{ steps.prep.outputs.VERSION }} - path: Downloads - - name: Download Artifact Linux arm64 - uses: actions/download-artifact@v3 + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push + uses: docker/build-push-action@v5.0.0 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: install/docker/Dockerfile.Action + platforms: linux/arm,linux/arm64,linux/amd64 + push: true + tags: | + ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }} + ${{ steps.prep.outputs.image }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max + Release_v2rayA_GUI_to_Docker: + runs-on: ubuntu-22.04 + needs: [GitHub_Release] + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v3 with: - name: v2raya_linux_arm64_${{ steps.prep.outputs.VERSION }} - path: Downloads - - name: Download Artifact Linux armv7 + fetch-depth: 0 + - name: Check Version + id: prep + run: | + tag=$(git describe --tags $(git rev-list --tags --max-count=1)) + version=${tag:1} + echo "VERSION=$version" >> $GITHUB_OUTPUT + echo "VERSION=$version" >> $GITHUB_ENV + TAG=$(echo $GITHUB_REF | cut -d / -f 3) + IMAGE="mzz2017/v2raya-gui" + echo image=${IMAGE} >> $GITHUB_OUTPUT + - name: Download Web Files uses: actions/download-artifact@v3 with: - name: v2raya_linux_armv7_${{ steps.prep.outputs.VERSION }} - path: Downloads + name: web + path: web - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 - name: Set up Docker Buildx @@ -758,10 +788,14 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build Docker Images - shell: bash - run: | - Current_Path=$(pwd) - mkdir build_docker && cd build_docker && mkdir build - cat $Current_Path/install/docker/Dockerfile.Action | sed s/Real_v2rayA_PATH/$Current_Path/Downloads/v2raya_linux_x64_${{ steps.prep.outputs.VERSION }}/g > Dockerfile.Action_x64 - docker buildx build --platform linux/amd64 -f Dockerfile.Action_x64 -t $IMAGE:$TAG ./build + - name: Build and push + uses: docker/build-push-action@v5.0.0 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: install/docker/Dockerfile.GUI.Action + platforms: linux/arm,linux/arm64,linux/amd64 + push: true + tags: mzz2017/v2raya-gui:latest + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/install/docker/Dockerfile.Action b/install/docker/Dockerfile.Action index 758ec17d5e..e08a28fc41 100644 --- a/install/docker/Dockerfile.Action +++ b/install/docker/Dockerfile.Action @@ -1,7 +1,9 @@ -FROM alpine:latest +FROM alpine:latest AS builder +WORKDIR /build +COPY ./install/docker/docker_helper.sh ./docker_helper.sh +RUN sh -c "$(cat ./docker_helper.sh)" RUN apk add --no-cache iptables ip6tables nftables -COPY Real_v2rayA_PATH /usr/bin/v2raya -CMD [“/usr/bin/v2raya”] +RUN rm ./docker_helper.sh EXPOSE 2017 VOLUME /etc/v2raya -ENTRYPOINT ["v2raya"] \ No newline at end of file +ENTRYPOINT ["v2raya"] diff --git a/install/docker/Dockerfile.GUI.Action b/install/docker/Dockerfile.GUI.Action new file mode 100644 index 0000000000..e2729ecf62 --- /dev/null +++ b/install/docker/Dockerfile.GUI.Action @@ -0,0 +1,4 @@ +FROM nginx:stable-alpine +WORKDIR /build +COPY ./web /usr/share/nginx/html +EXPOSE 80 \ No newline at end of file diff --git a/install/docker/docker_helper.sh b/install/docker/docker_helper.sh new file mode 100644 index 0000000000..6c5cf0602e --- /dev/null +++ b/install/docker/docker_helper.sh @@ -0,0 +1,35 @@ +#!/bin/sh +set -x +current_dir=$(pwd) +mkdir "$current_dir"/cache && cd "$current_dir"/cache || exit +case "$(arch)" in + x86_64) + v2ray_arch="64" + v2raya_arch="x64" + ;; + armv7l) + v2ray_arch="arm32-v7a" + v2raya_arch="armv7" + ;; + aarch64) + v2ray_arch="arm64-v8a" + v2raya_arch="arm64" + ;; + *) + ;; +esac +wget https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-linux-$v2ray_arch.zip +wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-$v2ray_arch.zip +wget https://github.com/v2rayA/v2rayA/releases/download/vRealv2rayAVersion/v2raya_linux_"$v2raya_arch"_Realv2rayAVersion +unzip v2ray-linux-"$v2ray_arch".zip -d v2ray +install ./v2ray/v2ray /usr/local/bin/v2ray +unzip Xray-linux-"$v2ray_arch".zip -d xray +install ./xray/xray /usr/local/bin/xray +install ./v2raya_linux_"$v2raya_arch"_Realv2rayAVersion /usr/bin/v2raya +mkdir /usr/local/share/v2raya +ln -s /usr/local/share/v2ray /usr/local/share/v2raya +ln -s /usr/local/share/xray /usr/local/share/v2raya +wget -O /usr/local/share/v2raya/LoyalsoldierSite.dat https://raw.githubusercontent.com/mzz2017/dist-v2ray-rules-dat/master/geosite.dat +wget -O /usr/local/share/v2raya/geosite.dat https://raw.githubusercontent.com/mzz2017/dist-v2ray-rules-dat/master/geosite.dat +wget -O /usr/local/share/v2raya/geoip.dat https://raw.githubusercontent.com/mzz2017/dist-v2ray-rules-dat/master/geoip.dat +cd "$current_dir" && rm -rf "$current_dir"/cache