From eaaca6cffd9bc644a239de2d02746ebedaa6ae13 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 30 Oct 2026 04:58:27 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E8=BF=81=E7=A7=BB=E5=88=B0=20Gitea=20Act?= =?UTF-8?q?ions=EF=BC=8C=E6=9E=84=E5=BB=BA=E7=BA=AF=20server=20=E9=95=9C?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 Dockerfile.ci:rust musl 静态编译 hbbs/hbbr/rustdesk-utils + alpine/s6(移除 api 服务,避免 21114 冲突) - 新增 ci-docker.yml(check/docker/deploy)与 docker-compose.prod.yml - 删除旧的 GitHub Actions 工作流 --- .github/workflows/build-test.yaml | 181 ----------- .github/workflows/build.yaml | 516 ------------------------------ .github/workflows/ci-docker.yml | 119 +++++++ .github/workflows/ghcr.yml | 335 ------------------- .github/workflows/test.yml | 84 ----- Dockerfile.ci | 73 +++++ docker-compose.prod.yml | 25 ++ 7 files changed, 217 insertions(+), 1116 deletions(-) delete mode 100644 .github/workflows/build-test.yaml delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/ci-docker.yml delete mode 100644 .github/workflows/ghcr.yml delete mode 100644 .github/workflows/test.yml create mode 100644 Dockerfile.ci create mode 100644 docker-compose.prod.yml diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml deleted file mode 100644 index 8b42c45..0000000 --- a/.github/workflows/build-test.yaml +++ /dev/null @@ -1,181 +0,0 @@ -name: build-test - -# ------------- NOTE -# please setup some secrets before running this workflow: -# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" ) -# DOCKER_IMAGE_CLASSIC should be the target image name on docker hub for the old build (e.g. "rustdesk/rustdesk-server" ) -# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/ -# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access - -on: - workflow_dispatch: - push: - tags: - - 'test.*' - -env: - CARGO_TERM_COLOR: always - LATEST_TAG: latest - -jobs: - - # binary build - build: - - name: Build - ${{ matrix.job.name }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", target: "x86_64-unknown-linux-musl" } - - { name: "arm64v8", target: "aarch64-unknown-linux-musl" } - - { name: "armv7", target: "armv7-unknown-linux-musleabihf" } - - { name: "i386", target: "i686-unknown-linux-musl" } - #- { name: "amd64fb", target: "x86_64-unknown-freebsd" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - default: true - components: rustfmt - profile: minimal - target: ${{ matrix.job.target }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features --target=${{ matrix.job.target }} - use-cross: true - - - name: Exec chmod - run: chmod -v a+x target/${{ matrix.job.target }}/release/* - - - name: Publish Artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: | - target/${{ matrix.job.target }}/release/hbbr - target/${{ matrix.job.target }}/release/hbbs - target/${{ matrix.job.target }}/release/rustdesk-utils - if-no-files-found: error - - - # docker build and push of single-arch images - docker: - - name: Docker push - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" } - - { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" } - - { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" } -# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: docker/rootfs/usr/bin - - - name: Make binaries executable - run: chmod -v a+x docker/rootfs/usr/bin/* - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: "./docker" - platforms: ${{ matrix.job.docker_platform }} - push: true - provenance: false - build-args: | - S6_ARCH=${{ matrix.job.s6_platform }} - tags: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-${{ matrix.job.name }} - labels: ${{ steps.meta.outputs.labels }} - - # docker build and push of multiarch images - docker-manifest: - - name: Docker manifest s6 - needs: docker - runs-on: ubuntu-24.04 - - steps: - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - # manifest for :1.2.3 tag - # this has to run only if invoked by a new tag - - name: Create and push manifest (:ve.rs.ion) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }} - inputs: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64, - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8, - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7, -# ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386 - push: true \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 73a1908..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,516 +0,0 @@ -name: build - -# ------------- NOTE -# please setup some secrets before running this workflow: -# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" ) -# DOCKER_IMAGE_CLASSIC should be the target image name on docker hub for the old build (e.g. "rustdesk/rustdesk-server" ) -# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/ -# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access - -on: - workflow_dispatch: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+-[0-9]+' - -env: - CARGO_TERM_COLOR: always - LATEST_TAG: latest - -jobs: - - # binary build - build: - - name: Build - ${{ matrix.job.name }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", target: "x86_64-unknown-linux-musl" } - - { name: "arm64v8", target: "aarch64-unknown-linux-musl" } - - { name: "armv7", target: "armv7-unknown-linux-musleabihf" } - - { name: "i386", target: "i686-unknown-linux-musl" } - #- { name: "amd64fb", target: "x86_64-unknown-freebsd" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - default: true - components: rustfmt - profile: minimal - target: ${{ matrix.job.target }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features --target=${{ matrix.job.target }} - use-cross: true - - - name: Exec chmod - run: chmod -v a+x target/${{ matrix.job.target }}/release/* - - - name: Publish Artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: | - target/${{ matrix.job.target }}/release/hbbr - target/${{ matrix.job.target }}/release/hbbs - target/${{ matrix.job.target }}/release/rustdesk-utils - if-no-files-found: error - - build-win: - name: Build - windows - runs-on: windows-2022 - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - default: true - components: rustfmt - profile: minimal - target: x86_64-pc-windows-msvc - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features --target=x86_64-pc-windows-msvc - use-cross: true - - - name: Install NSIS - run: | - iwr -useb get.scoop.sh -outfile 'install.ps1' - .\install.ps1 -RunAsAdmin - scoop update - scoop bucket add extras - scoop install nsis - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Sign exe files - uses: GermanBluefox/code-sign-action@v7 - if: false - with: - certificate: '${{ secrets.WINDOWS_PFX_BASE64 }}' - password: '${{ secrets.WINDOWS_PFX_PASSWORD }}' - certificatesha1: '${{ secrets.WINDOWS_PFX_SHA1_THUMBPRINT }}' - folder: 'target\x86_64-pc-windows-msvc\release' - recursive: false - - - name: Build UI browser file - run: | - npm i - npm run build - working-directory: ./ui/html - - - name: Build UI setup file - run: | - rustup default nightly - cargo build --release - xcopy /y ..\target\x86_64-pc-windows-msvc\release\*.exe setup\bin\ - xcopy /y target\release\*.exe setup\ - mkdir setup\logs - makensis /V1 setup.nsi - mkdir SignOutput - mv RustDeskServer.Setup.exe SignOutput\ - mv ..\target\x86_64-pc-windows-msvc\release\*.exe SignOutput\ - working-directory: ./ui - - - name: Sign UI setup file - uses: GermanBluefox/code-sign-action@v7 - if: false - with: - certificate: '${{ secrets.WINDOWS_PFX_BASE64 }}' - password: '${{ secrets.WINDOWS_PFX_PASSWORD }}' - certificatesha1: '${{ secrets.WINDOWS_PFX_SHA1_THUMBPRINT }}' - folder: './ui/SignOutput' - recursive: false - - - name: Publish Artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries-windows-x86_64 - path: | - ui\SignOutput\hbbr.exe - ui\SignOutput\hbbs.exe - ui\SignOutput\rustdesk-utils.exe - ui\SignOutput\RustDeskServer.Setup.exe - if-no-files-found: error - - # github (draft) release with all binaries - release: - - name: Github release - needs: - - build - - build-win - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { os: "linux", name: "amd64", suffix: "" } - - { os: "linux", name: "arm64v8", suffix: "" } - - { os: "linux", name: "armv7", suffix: "" } - - { os: "linux", name: "i386", suffix: "" } - #- { os: "linux", name: "amd64fb", suffix: "" } - - { os: "windows", name: "x86_64", suffix: "-unsigned" } - - steps: - - - name: Download binaries (${{ matrix.job.os }} - ${{ matrix.job.name }}) - uses: actions/download-artifact@v4 - with: - name: binaries-${{ matrix.job.os }}-${{ matrix.job.name }} - path: ${{ matrix.job.name }} - - - name: Exec chmod - run: chmod -v a+x ${{ matrix.job.name }}/* - - - name: Pack files (${{ matrix.job.os }} - ${{ matrix.job.name }}) - run: | - sudo apt update - DEBIAN_FRONTEND=noninteractive sudo apt install -y zip - zip ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}${{ matrix.job.suffix }}.zip ${{ matrix.job.name }}/* - - - name: Create Release (${{ matrix.job.os }} - (${{ matrix.job.name }}) - uses: softprops/action-gh-release@v1 - with: - draft: true - files: ${{ matrix.job.name }}/rustdesk-server-${{ matrix.job.os }}-${{ matrix.job.name }}${{ matrix.job.suffix }}.zip - - # docker build and push of single-arch images - docker: - - name: Docker push - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" } - - { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" } - - { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" } -# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: docker/rootfs/usr/bin - - - name: Make binaries executable - run: chmod -v a+x docker/rootfs/usr/bin/* - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: "./docker" - platforms: ${{ matrix.job.docker_platform }} - push: true - provenance: false - build-args: | - S6_ARCH=${{ matrix.job.s6_platform }} - tags: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-${{ matrix.job.name }} - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-${{ matrix.job.name }} - ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-${{ matrix.job.name }} - labels: ${{ steps.meta.outputs.labels }} - - # docker build and push of multiarch images - docker-manifest: - - name: Docker manifest s6 - needs: docker - runs-on: ubuntu-24.04 - - steps: - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - # manifest for :1.2.3 tag - # this has to run only if invoked by a new tag - - name: Create and push manifest (:ve.rs.ion) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }} - inputs: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64, - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8, - ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7, -# ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386 - push: true - - # manifest for :1 tag (major release) - - name: Create and push manifest (:major) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }} - inputs: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-amd64, - ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-arm64v8, - ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-armv7, -# ${{ secrets.DOCKER_IMAGE }}:${{ env.MAJOR_TAG }}-i386 - push: true - - # manifest for :latest tag - - name: Create and push manifest (:latest) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }} - inputs: | - ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-amd64, - ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-arm64v8, - ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-armv7, -# ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-i386 - push: true - - - # docker build and push of single-arch images - docker-classic: - - name: Docker push classic - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", docker_platform: "linux/amd64" } - - { name: "arm64v8", docker_platform: "linux/arm64" } - - { name: "armv7", docker_platform: "linux/arm/v7" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: docker-classic/ - - - name: Make binaries executable - run: chmod -v a+x docker-classic/* - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE_CLASSIC }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: "./docker-classic" - platforms: ${{ matrix.job.docker_platform }} - push: true - provenance: false - tags: | - ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-${{ matrix.job.name }} - ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-${{ matrix.job.name }} - ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-${{ matrix.job.name }} - labels: ${{ steps.meta.outputs.labels }} - - # docker build and push of multiarch images - docker-manifest-classic: - - name: Docker manifest classic - needs: docker - runs-on: ubuntu-24.04 - steps: - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - # manifest for :1.2.3 tag - # this has to run only if invoked by a new tag - - name: Create and push manifest (:ve.rs.ion) - uses: Noelware/docker-manifest-action@master - if: github.event_name != 'workflow_dispatch' - with: - tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }} - inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.GIT_TAG }}-armv7 - push: true - - # manifest for :1 tag (major release) - - name: Create and push manifest (:major) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }} - inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.MAJOR_TAG }}-armv7 - push: true - - # manifest for :latest tag - - name: Create and push manifest (:latest) - uses: Noelware/docker-manifest-action@master - with: - tags: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }} - inputs: ${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE_CLASSIC }}:${{ env.LATEST_TAG }}-armv7 - push: true - - - deb-package: - - name: debian package - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", debian_platform: "amd64", crossbuild_package: "" } - - { name: "arm64v8", debian_platform: "arm64", crossbuild_package: "crossbuild-essential-arm64" } - - { name: "armv7", debian_platform: "armhf", crossbuild_package: "crossbuild-essential-armhf" } - - { name: "i386", debian_platform: "i386", crossbuild_package: "crossbuild-essential-i386" } - - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Create packaging env - run: | - sudo apt update - DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }} - mkdir -p debian-build/${{ matrix.job.name }}/bin - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: debian-build/${{ matrix.job.name }}/bin - - - name: Build package for ${{ matrix.job.name }} arch - run: | - chmod -v a+x debian-build/${{ matrix.job.name }}/bin/* - cp -vr debian systemd debian-build/${{ matrix.job.name }}/ - cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.name }}/debian/control - cd debian-build/${{ matrix.job.name }}/ - debuild -i -us -uc -b -a${{ matrix.job.debian_platform }} - - - name: Create Release - uses: softprops/action-gh-release@v1 - with: - draft: true - files: | - debian-build/rustdesk-server-hbbr_*_${{ matrix.job.debian_platform }}.deb - debian-build/rustdesk-server-hbbs_*_${{ matrix.job.debian_platform }}.deb - debian-build/rustdesk-server-utils_*_${{ matrix.job.debian_platform }}.deb diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml new file mode 100644 index 0000000..c805a62 --- /dev/null +++ b/.github/workflows/ci-docker.yml @@ -0,0 +1,119 @@ +name: CI and Docker Build + +on: + push: + branches: + - master + - main + - forapi + tags: + - 'v*' + pull_request: + branches: + - master + - main + - forapi + +jobs: + check: + name: Cargo Check + runs-on: ubuntu + container: + image: rust:1.75 + + steps: + - name: Checkout and check + run: | + cd /tmp + git clone --depth=1 -b ${{ github.ref_name }} https://admin:${{ secrets.TOKEN }}@git.viaeon.com/admin/rustdesk-server.git repo + cd repo + git config --global --add safe.directory '*' + git submodule update --init --recursive + cargo check --all-features + + docker: + name: Build and Push Docker Image + runs-on: ubuntu + needs: [check] + if: github.event_name == 'push' + env: + RUNNER_TOOL_CACHE: /toolcache + + steps: + - name: Install Docker CLI + run: | + if ! command -v docker &> /dev/null; then + if command -v apk &> /dev/null; then + apk add --no-cache docker-cli + elif command -v apt-get &> /dev/null; then + apt-get update && apt-get install -y docker.io + else + curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | tar xz -C /tmp + mv /tmp/docker/docker /usr/local/bin/ + chmod +x /usr/local/bin/docker + fi + fi + docker --version + + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Login to Gitea Container Registry + run: | + echo "${{ secrets.TOKEN }}" | docker login git.viaeon.com -u "${{ github.actor }}" --password-stdin 2>&1 + + - name: Build Docker image + run: | + echo "Building image..." + docker build \ + --label "org.opencontainers.image.source=https://git.viaeon.com/admin/rustdesk-server" \ + --label "org.opencontainers.image.revision=${{ github.sha }}" \ + -f Dockerfile.ci \ + -t git.viaeon.com/admin/rustdesk-server:${{ github.ref_name }} \ + -t git.viaeon.com/admin/rustdesk-server:latest . 2>&1 + + - name: Push Docker image + run: | + echo "Pushing ${{ github.ref_name }}..." + docker push git.viaeon.com/admin/rustdesk-server:${{ github.ref_name }} 2>&1 + echo "Pushing latest..." + docker push git.viaeon.com/admin/rustdesk-server:latest 2>&1 + + deploy: + name: Deploy to Remote Server + runs-on: ubuntu + needs: docker + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/forapi') + env: + RUNNER_TOOL_CACHE: /toolcache + + steps: + - name: Install SSH Client + run: | + if command -v apk &> /dev/null; then + apk add --no-cache openssh-client sshpass + elif command -v apt-get &> /dev/null; then + apt-get update && apt-get install -y openssh-client sshpass + else + echo "Cannot install sshpass" + exit 1 + fi + ssh -V + + - name: Deploy via SSH + run: | + sshpass -p '${{ secrets.DEPLOY_PASSWORD }}' ssh -o StrictHostKeyChecking=no -p ${{ secrets.DEPLOY_PORT || '22' }} ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << ENDSSH + set -e + cd "${{ secrets.DEPLOY_PATH }}" + echo "Current directory: \$(pwd)" + echo "Pulling latest image..." + docker pull git.viaeon.com/admin/rustdesk-server:latest + echo "Restarting containers..." + docker compose down || true + docker compose up -d + echo "Cleaning up old images..." + docker image prune -f + echo "Deployment completed!" + ENDSSH diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml deleted file mode 100644 index 806084c..0000000 --- a/.github/workflows/ghcr.yml +++ /dev/null @@ -1,335 +0,0 @@ -name: Build and publish to ghcr.io - -on: - workflow_dispatch: - push: - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-[0-9]+' - - '[0-9]+.[0-9]+.[0-9]+-[0-9]+' - -env: - CARGO_TERM_COLOR: always - LATEST_TAG: latest - -permissions: - contents: read - packages: write # So need to set "secrets.GITHUB_TOKEN" - -jobs: - - # Binary build - build: - name: Build - ${{ matrix.job.name }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", target: "x86_64-unknown-linux-musl" } - - { name: "arm64v8", target: "aarch64-unknown-linux-musl" } - - { name: "armv7", target: "armv7-unknown-linux-musleabihf" } - - { name: "i386", target: "i686-unknown-linux-musl" } - #- { name: "amd64fb", target: "x86_64-unknown-freebsd" } - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: stable - targets: ${{ matrix.job.target }} - components: "rustfmt" - - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: ${{ matrix.job.os }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features --target=${{ matrix.job.target }} - use-cross: true - - - name: Exec chmod - run: chmod -v a+x target/${{ matrix.job.target }}/release/* - - - name: Publish Artifacts - uses: actions/upload-artifact@v4 - with: - name: binaries-linux-${{ matrix.job.name }} - path: | - target/${{ matrix.job.target }}/release/hbbr - target/${{ matrix.job.target }}/release/hbbs - target/${{ matrix.job.target }}/release/rustdesk-utils - if-no-files-found: error - - # Build and push single-arch Docker images to ghcr.io - create-s6-overlay-images: - name: Docker push s6-overlay - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" } - - { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" } - - { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" } -# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" } - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - pattern: binaries-linux-${{ matrix.job.name }} - path: docker/rootfs/usr/bin - merge-multiple: true - - - name: Make binaries executable - run: chmod -v a+x docker/rootfs/usr/bin/* - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }}-s6 - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: "./docker" - platforms: ${{ matrix.job.docker_platform }} - push: true - provenance: false - build-args: | - S6_ARCH=${{ matrix.job.s6_platform }} - tags: | - ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-${{ matrix.job.name }} - ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-${{ matrix.job.name }} - ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-${{ matrix.job.name }} - labels: ${{ steps.meta.outputs.labels }} - - # Set up minifest and tag for pushed image - create-s6-overlay-images-manifest: - name: Manifest for s6-overlay images - needs: create-s6-overlay-images - runs-on: ubuntu-24.04 - - steps: - - name: Log in to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - # Create and push manifest for :ve.rs.ion tag - - name: Create and push manifest (:ve.rs.ion) - uses: Noelware/docker-manifest-action@master - if: github.event_name != 'workflow_dispatch' - with: - tags: ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }} - inputs: | - ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-amd64, - ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-armv7, -# ghcr.io/${{ github.repository }}-s6:${{ env.GIT_TAG }}-i386 - push: true - - # Create and push manifest for :major tag - - name: Create and push manifest (:major) - uses: Noelware/docker-manifest-action@master - with: - tags: ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }} - inputs: | - ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-amd64, - ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-armv7, -# ghcr.io/${{ github.repository }}-s6:${{ env.MAJOR_TAG }}-i386 - push: true - - # Create and push manifest for :latest tag - - name: Create and push manifest (:latest) - uses: Noelware/docker-manifest-action@master - with: - tags: ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }} - inputs: | - ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-amd64, - ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-armv7, -# ghcr.io/${{ github.repository }}-s6:${{ env.LATEST_TAG }}-i386 - push: true - - # Build and push single-arch Docker images to ghcr.io - create-classic-images: - name: Docker push classic - ${{ matrix.job.name }} - needs: build - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - job: - - { name: "amd64", docker_platform: "linux/amd64" } - - { name: "arm64v8", docker_platform: "linux/arm64" } - - { name: "armv7", docker_platform: "linux/arm/v7" } - - { name: "i386", docker_platform: "linux/386" } - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Download binaries - uses: actions/download-artifact@v4 - with: - pattern: binaries-linux-${{ matrix.job.name }} - path: docker-classic - merge-multiple: true - - - name: Make binaries executable - run: chmod -v a+x docker-classic/* - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: "./docker-classic" - platforms: ${{ matrix.job.docker_platform }} - push: true - provenance: false - tags: | - ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-${{ matrix.job.name }} - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-${{ matrix.job.name }} - ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-${{ matrix.job.name }} - labels: ${{ steps.meta.outputs.labels }} - - # Set up minifest and tag for pushed image - create-classic-images-manifest: - name: Manifest for classic images - needs: create-classic-images - runs-on: ubuntu-24.04 - - steps: - - name: Log in to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get git tag - id: vars - run: | - T=${GITHUB_REF#refs/*/} - M=${T%%.*} - echo "GIT_TAG=$T" >> $GITHUB_ENV - echo "MAJOR_TAG=$M" >> $GITHUB_ENV - - # Create and push manifest for :ve.rs.ion tag - - name: Create and push manifest (:ve.rs.ion) - uses: Noelware/docker-manifest-action@master - if: github.event_name != 'workflow_dispatch' - with: - tags: ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }} - inputs: | - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-amd64, - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-armv7, - ghcr.io/${{ github.repository }}:${{ env.GIT_TAG }}-i386 - push: true - - # Create and push manifest for :major tag - - name: Create and push manifest (:major) - uses: Noelware/docker-manifest-action@master - with: - tags: ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }} - inputs: | - ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-amd64, - ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-armv7, - ghcr.io/${{ github.repository }}:${{ env.MAJOR_TAG }}-i386 - push: true - - # Create and push manifest for :latest tag - - name: Create and push manifest (:latest) - uses: Noelware/docker-manifest-action@master - with: - tags: ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }} - inputs: | - ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-amd64, - ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-arm64v8, - ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-armv7, - ghcr.io/${{ github.repository }}:${{ env.LATEST_TAG }}-i386 - push: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 2d8345a..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: test - -on: - push: - branches: [ "master" ] - paths-ignore: - - '**/README.md' - pull_request: - branches: [ "master" ] - paths-ignore: - - '**/README.md' - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - - uses: actions-rs/cargo@v1 - with: - command: check - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - - uses: actions-rs/cargo@v1 - with: - command: test - args: --all - - fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - uses: Swatinem/rust-cache@v2 - - uses: actions-rs/cargo@v1 - with: - command: build - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy - - uses: Swatinem/rust-cache@v2 - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all -- -D warnings diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..c84777c --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,73 @@ +# 自建 Gitea CI 使用的镜像构建文件 +# 与官方 docker/Dockerfile 的区别: +# 1. 编译在构建阶段内完成(rust:1.75 + musl 静态链接),不依赖外部预编译产物 +# 2. 基础镜像改为 alpine,不含 apimain(API 由独立的 rustdesk-api 容器提供,避免抢占 21114) +# 3. 保留 s6-overlay 与 key-secret 服务,因此 hbbs 会在首次启动时生成 /data/id_ed25519{,.pub} +# +# 构建(在仓库根目录执行,需要 .git 以拉取 submodule): +# docker build -f Dockerfile.ci -t git.viaeon.com/admin/rustdesk-server:latest . + +FROM rust:1.75 AS builder + +ARG TARGET=x86_64-unknown-linux-musl + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + musl-tools \ + pkg-config \ + ca-certificates \ + git \ + && rm -rf /var/lib/apt/lists/* \ + && rustup target add ${TARGET} + +WORKDIR /src +COPY . /src + +RUN git config --global --add safe.directory '*' \ + && git submodule update --init --recursive + +RUN CC_x86_64_unknown_linux_musl=musl-gcc \ + CARGO_NET_GIT_FETCH_WITH_CLI=true \ + cargo build --release --all-features --target ${TARGET} + +RUN mkdir -p /out \ + && cp target/${TARGET}/release/hbbs /out/hbbs \ + && cp target/${TARGET}/release/hbbr /out/hbbr \ + && cp target/${TARGET}/release/rustdesk-utils /out/rustdesk-utils + +FROM alpine:3.20 + +ARG S6_OVERLAY_VERSION=3.2.0.0 +ARG S6_ARCH=x86_64 + +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_ARCH}.tar.xz /tmp + +RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz \ + && tar -C / -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz \ + && rm -f /tmp/s6-overlay*.tar.xz \ + && ln -s /run /var/run + +COPY docker/rootfs/ / + +# 去掉 API 服务:本机由单独的 rustdesk-api 容器提供,避免 21114 端口冲突 +RUN rm -rf /etc/s6-overlay/s6-rc.d/api \ + /etc/s6-overlay/s6-rc.d/user/contents.d/api + +COPY --from=builder /out/hbbs /usr/bin/hbbs +COPY --from=builder /out/hbbr /usr/bin/hbbr +COPY --from=builder /out/rustdesk-utils /usr/bin/rustdesk-utils + +RUN chmod a+x /usr/bin/hbbs /usr/bin/hbbr /usr/bin/rustdesk-utils /usr/bin/healthcheck.sh + +ENV RELAY=relay.example.com +ENV ENCRYPTED_ONLY=0 + +VOLUME /data +WORKDIR /data + +EXPOSE 21115 21116 21116/udp 21117 21118 21119 + +HEALTHCHECK --interval=10s --timeout=5s CMD /usr/bin/healthcheck.sh + +ENTRYPOINT ["/init"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..c500709 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,25 @@ +# 部署端使用的 compose(放到服务器的 DEPLOY_PATH 目录下) +# 只跑 ID/中继服务;API 由 rustdesk-api 的 compose 单独提供 +# 首次启动后从容器取公钥:docker exec rustdesk-server cat /data/id_ed25519.pub + +services: + rustdesk-server: + image: git.viaeon.com/admin/rustdesk-server:latest + container_name: rustdesk-server + restart: unless-stopped + ports: + - "21115:21115" + - "21116:21116" + - "21116:21116/udp" + - "21117:21117" + - "21118:21118" + - "21119:21119" + volumes: + - ./data:/data + environment: + # 改成你的服务器地址(客户端填的中继服务器) + RELAY: 你的域名或公网IP:21117 + ENCRYPTED_ONLY: 0 + # 可选:固定密钥对,避免重建后 key 变化 + # KEY_PUB: "" + # KEY_PRIV: ""