From 4af410d4dcb987ff560cc8dd21a6eaee677e765e Mon Sep 17 00:00:00 2001 From: Markson Hon Date: Sun, 12 Nov 2023 11:14:33 +0800 Subject: [PATCH] test: rewrite stable docker image build --- .github/workflows/dockerimage.yml | 46 ------------------------ .github/workflows/release_main.yml | 58 ++++++++++++++++++++++++++++-- install/docker/Dockerfile.Action | 7 ++++ 3 files changed, 62 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml create mode 100644 install/docker/Dockerfile.Action diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index bef2b31a4d..0000000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: v2raya-docker - -on: - push: - tags: - - v* - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Prepare - id: prep - run: | - TAG=$(echo $GITHUB_REF | cut -d / -f 3) - IMAGE="mzz2017/v2raya" - echo image=${IMAGE} >> $GITHUB_OUTPUT - echo tag=${TAG:1} >> $GITHUB_OUTPUT - - - 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 }} - - # https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md - - name: Build production image - uses: docker/build-push-action@v2 - with: - context: . - builder: ${{ steps.buildx.outputs.name }} - file: Dockerfile - 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 diff --git a/.github/workflows/release_main.yml b/.github/workflows/release_main.yml index bd3cfc9090..3b8b37da31 100644 --- a/.github/workflows/release_main.yml +++ b/.github/workflows/release_main.yml @@ -1,4 +1,5 @@ name: Build & Release v2rayA + on: workflow_dispatch: push: @@ -676,17 +677,17 @@ jobs: version=${tag:1} echo "VERSION=$version" >> $GITHUB_OUTPUT echo "VERSION=$version" >> $GITHUB_ENV - - name: Download Artifacts Linux x64 + - name: Download Artifact Linux x64 uses: actions/download-artifact@v3 with: name: v2raya_linux_x64_${{ steps.prep.outputs.VERSION }} path: Downloads - - name: Download Artifacts macOS x64 + - name: Download Artifact macOS x64 uses: actions/download-artifact@v3 with: name: v2raya_darwin_x64_${{ steps.prep.outputs.VERSION }} path: Downloads - - name: Download Artifacts macOS arm64 + - name: Download Artifact macOS arm64 uses: actions/download-artifact@v3 with: name: v2raya_darwin_arm64_${{ steps.prep.outputs.VERSION }} @@ -713,3 +714,54 @@ 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: + runs-on: ubuntu-22.04 + needs: [Build_v2rayA_Binaries] + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - 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 + echo "VERSION=$version" >> $GITHUB_ENV + 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 + with: + name: v2raya_linux_x64_${{ steps.prep.outputs.VERSION }} + path: Downloads + - name: Download Artifact Linux arm64 + uses: actions/download-artifact@v3 + with: + name: v2raya_linux_arm64_${{ steps.prep.outputs.VERSION }} + path: Downloads + - name: Download Artifact Linux armv7 + uses: actions/download-artifact@v3 + with: + name: v2raya_linux_armv7_${{ steps.prep.outputs.VERSION }} + path: Downloads + - 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: + 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 diff --git a/install/docker/Dockerfile.Action b/install/docker/Dockerfile.Action new file mode 100644 index 0000000000..758ec17d5e --- /dev/null +++ b/install/docker/Dockerfile.Action @@ -0,0 +1,7 @@ +FROM alpine:latest +RUN apk add --no-cache iptables ip6tables nftables +COPY Real_v2rayA_PATH /usr/bin/v2raya +CMD [“/usr/bin/v2raya”] +EXPOSE 2017 +VOLUME /etc/v2raya +ENTRYPOINT ["v2raya"] \ No newline at end of file