From ea41232bc659236348d84063be1d039d613864bc Mon Sep 17 00:00:00 2001 From: soul-walker Date: Thu, 28 Mar 2024 09:54:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9submodule=20url=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0local-test=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/CICD_local_test.yaml | 61 +++++++++++++++++++++++++++ .gitmodules | 2 +- Dockerfile | 11 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/CICD_local_test.yaml create mode 100644 Dockerfile diff --git a/.gitea/workflows/CICD_local_test.yaml b/.gitea/workflows/CICD_local_test.yaml new file mode 100644 index 0000000..0076927 --- /dev/null +++ b/.gitea/workflows/CICD_local_test.yaml @@ -0,0 +1,61 @@ +name: local-test分支构建docker并发布运行 +run-name: ${{ gitea.actor }} is testing out Gitea Actions +on: + push: + branches: + - local-test + +jobs: + Docker-Build: + runs-on: joylink-local233 + steps: + - name: 检出代码 + uses: https://gitea.joylink.club/actions/checkout@v4 + with: + submodules: recursive + - name: 设置java环境 + uses: https://gitea.joylink.club/actions/setup-java@v4 + with: + java-version: '17' + distribution: 'zulu' + cache: 'maven' + cache-dependency-path: './pom.xml' + - name: 设置Maven环境 + uses: https://gitea.joylink.club/actions/local-setup-maven@v0.1.1 + with: + maven-version: 3.8.8 + - name: 构建 + run: | + mvn -Dmaven.test.skip=true clean package + - name: 设置 Docker + uses: https://gitea.joylink.club/actions/local-setup-docker-cli-action@v0.1.1 + - name: 设置 Docker Buildx + uses: https://gitea.joylink.club/actions/local-setup-buildx-action@v0.1.3 + - name: docker登录gitea.joylink.club + uses: https://gitea.joylink.club/docker/login-action@v3 + with: + registry: gitea.joylink.club + username: shengxuqiang + password: ${{ secrets.SHENGXUQIANG_PASSWORD }} + - name: Docker Build and push + uses: https://gitea.joylink.club/docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: | + gitea.joylink.club/joylink/xian-ncc-da-service:local-test + - name: 发布到本地测试环境 + uses: https://gitea.joylink.club/appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.LOCAL_233_SSH_HOST }} + port: ${{ secrets.LOCAL_233_SSH_PORT }} + username: ${{ secrets.LOCAL_233_SSH_USER }} + password: ${{ secrets.LOCAL_233_SSH_PASSWORD }} + script: | + docker rm -f xian-ncc-da-service || echo "xian-ncc-da-service not exist" + docker pull gitea.joylink.club/joylink/xian-ncc-da-service:local-test + docker run --name xian-ncc-da-service --restart=always --network net --ip 192.168.53.181 -d -e APP_ENV=local-test -p 9081:9081 -v /usr/local/joylink/logs/xianncc:/usr/local/joylink/logs/xianncc gitea.joylink.club/joylink/xian-ncc-da-service:local-test + - name: 清理tag为none的镜像 + run: | + docker rmi $(docker images --filter "dangling=true" -q) \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 4467610..5189f34 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "xian-ncc-da-message"] path = xian-ncc-da-message - url = https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-message.git + url = https://gitea.joylink.club/joylink/xian-ncc-da-message.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5dab4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM azul/zulu-openjdk-alpine:17 + +ADD target/xian-ncc-da-0.1.jar xian-ncc-da.jar + +ENV APP_ENV=prd +EXPOSE 9081 + +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +CMD java -jar -Dfile.encoding=UTF-8 -Dspring.profiles.active=$APP_ENV /xian-ncc-da.jar