From d2537282c9882944eb4db6a37295f8f1e5e761d2 Mon Sep 17 00:00:00 2001 From: xrgzs Date: Tue, 17 Dec 2024 15:47:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20ghcr.io=20=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 14 ++++++++++++++ README.md | 25 +++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 76bc640..f81eaf5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -11,6 +11,7 @@ name: Java CI with Maven # The API requires write permission on the repository to submit dependencies permissions: contents: write + packages: write on: push: @@ -25,12 +26,23 @@ jobs: steps: - uses: actions/checkout@v3 + + - uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + cache-dependency-path: 'web-front/yarn.lock' + - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' cache: maven + + - name: Build Frontend + run: cd web-front && yarn install && yarn run build + - name: Build with Maven run: mvn -B package --file pom.xml @@ -43,3 +55,26 @@ jobs: # - uses: release-drafter/release-drafter@v5 # env: # GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + path: web-service/target/netdisk-fast-download-bin.zip + + - name: Login 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: Build and push Docker image + if: github.event_name != 'pull_request' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:${{ github.sha }} + ghcr.io/${{ github.repository }}:main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..359e207 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM eclipse-temurin:17-alpine + +WORKDIR /app + +COPY ./web-service/target/netdisk-fast-download-bin.zip . + +RUN unzip netdisk-fast-download-bin.zip && \ + mv netdisk-fast-download/* ./ && \ + rm netdisk-fast-download-bin.zip && \ + chmod +x run.sh + +EXPOSE 6400 6401 + +ENTRYPOINT ["sh", "run.sh"] diff --git a/README.md b/README.md index 689f656..d4cbbfa 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,31 @@ mvn package ``` 打包好的文件位于 web-service/target/netdisk-fast-download-bin.zip ## Linux服务部署 + +### Docker 部署(Main分支) + +```shell +# 创建目录 +mkdir -p netdisk-fast-download +cd netdisk-fast-download + +# 拉取镜像 +docker pull ghcr.io/qaiu/netdisk-fast-download:main + +# 复制配置文件(或下载仓库web-service\src\main\resources) +docker create --name netdisk-fast-download ghcr.io/qaiu/netdisk-fast-download:main +docker cp netdisk-fast-download:/app/resources ./resources +docker rm netdisk-fast-download + +# 启动容器 +docker run -d -it --name netdisk-fast-download -p 6401:6401 --restart unless-stopped -e TZ=Asia/Shanghai -v ./resources:/app/resources -v ./db:/app/db -v ./logs:/app/logs ghcr.io/qaiu/netdisk-fast-download:main + +# 反代6401端口 + +# 升级容器 +docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --run-once netdisk-fast-download +``` + ### [宝塔安装参考](https://blog.qaiu.top/archives/netdisk-fast-download-bao-ta-an-zhuang-jiao-cheng) > 注意: netdisk-fast-download.service中的ExecStart的路径改为实际路径 ```shell From f4ae1eaa515753bd5e4e3dff10287586006cd529 Mon Sep 17 00:00:00 2001 From: xrgzs Date: Tue, 17 Dec 2024 16:15:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?PR=E6=97=B6=E4=B8=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f81eaf5..76ad9de 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -49,6 +49,7 @@ jobs: # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph uses: advanced-security/maven-dependency-submission-action@v3 + if: github.event_name != 'pull_request' with: ignore-maven-wrapper: true