From 7524a6405849e304599b4b30cf5595e4a71546f8 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:28:20 +0000 Subject: [PATCH 01/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .gitea/workflows/build-dev.yaml diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml new file mode 100644 index 0000000..e69de29 From a31c4d2aafa54898118ff3da30240e562659407d Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:29:22 +0000 Subject: [PATCH 02/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 112 ++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml index e69de29..ee62f8c 100644 --- a/.gitea/workflows/build-dev.yaml +++ b/.gitea/workflows/build-dev.yaml @@ -0,0 +1,112 @@ +name: paipai-h5-dev + +on: + push: + branches: [main] + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + network=host + buildkitd-flags: | + --allow-insecure-entitlement security.insecure + + - name: Log in to container registry + uses: docker/login-action@v3 + with: + registry: code.paipai.life + username: ${{ secrets.DEV_DOCKER_USERNAME }} + password: ${{ secrets.DEV_DOCKER_PASSWORD }} + insecure: true + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: code.paipai.life/backend/rn-outside + tags: | + type=raw,value=latest + + - name: Build Docker image + run: | + docker build -t code.paipai.life/backend/rn-outside:latest . + + - name: Push Docker image + run: | + docker push code.paipai.life/backend/rn-outside:latest + env: + DOCKER_CONTENT_TRUST: 0 + + deploy: + runs-on: ubuntu-latest + needs: build-and-push + environment: test + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Copy files and deploy via SSH + uses: appleboy/scp-action@v0.1.3 + with: + host: ${{ secrets.DEV_SERVER_HOST }} + username: ${{ secrets.DEV_SERVER_USERNAME }} + password: ${{ secrets.DEV_SERVER_PASSWORD }} + port: 22 + source: "docker-compose-dev.yaml" + target: "/home/paipai/data/rn-outside" + override: true + + - name: Deploy with Docker Compose + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.DEV_SERVER_HOST }} + username: ${{ secrets.DEV_SERVER_USERNAME }} + password: ${{ secrets.DEV_SERVER_PASSWORD }} + port: 22 + script: | + # 切换到项目目录 + cd /home/paipai/data/rn-outside + + # 拉取最新镜像 + docker pull code.paipai.life/backend/rn-outside:latest + + # 使用 docker-compose 部署 + docker compose -f docker-compose-dev.yaml down + docker compose -f docker-compose-dev.yaml up -d + + echo "Deployment completed successfully!" + + cleanup: + runs-on: ubuntu-latest + needs: deploy + if: always() + + steps: + - name: Clean up Docker resources on server + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.DEV_SERVER_HOST }} + username: ${{ secrets.DEV_SERVER_USERNAME }} + password: ${{ secrets.DEV_SERVER_PASSWORD }} + port: 22 + script: | + docker image prune -f + docker container prune -f + docker builder prune -f + docker network prune -f + echo "Cleanup completed!" + + - name: Clean up GitHub Actions workspace + run: | + echo "Cleaning up GitHub Actions workspace..." + docker system df \ No newline at end of file From 89a5b5d19acab07419b0b3254f4a8e408cc5582f Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:31:47 +0000 Subject: [PATCH 03/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4696b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:20-alpine AS build + +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm install +COPY . . +RUN npm run build:h5 + + +FROM nginx:stable-alpine AS production + +COPY --from=build /app/dist/build/h5 /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From c475bcfe642a00be2baa8edcca0e14eb0d05d2ee Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:33:23 +0000 Subject: [PATCH 04/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20nginx.dev.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.dev.conf | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 nginx.dev.conf diff --git a/nginx.dev.conf b/nginx.dev.conf new file mode 100644 index 0000000..b873593 --- /dev/null +++ b/nginx.dev.conf @@ -0,0 +1,41 @@ +server { + listen 80; + server_name h5.dev.paipai.life; + + root /usr/share/nginx/html; + index index.html; + + # 设置客户端请求体超时时间 + client_body_timeout 300s; + + # API 代理配置 - 对应 proxy.ts 中的配置 + location /api/v1/ { + proxy_pass https://rn-master:8088/api/v1/; # 根据实际后端服务地址调整 + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # 代理超时设置 + proxy_connect_timeout 300s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + + # 代理缓冲区设置 + proxy_buffering off; + proxy_request_buffering off; + } + + # 单页应用路由配置 + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + # 静态资源缓存配置 + location /static { + expires 7d; + add_header Cache-Control "public, no-transform"; + } +} From 08624eb9be12a7307b000cf69ee4d97846e272b5 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:33:44 +0000 Subject: [PATCH 05/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20nginx.conf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..afa81fa --- /dev/null +++ b/nginx.conf @@ -0,0 +1,41 @@ +server { + listen 80; + server_name h5.paipai.life; + + root /usr/share/nginx/html; + index index.html; + + # 设置客户端请求体超时时间 + client_body_timeout 300s; + + # API 代理配置 - 对应 proxy.ts 中的配置 + location /api/v1/ { + proxy_pass https://rn-master:8088/api/v1/; # 根据实际后端服务地址调整 + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # 代理超时设置 + proxy_connect_timeout 300s; + proxy_send_timeout 300s; + proxy_read_timeout 300s; + + # 代理缓冲区设置 + proxy_buffering off; + proxy_request_buffering off; + } + + # 单页应用路由配置 + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + # 静态资源缓存配置 + location /static { + expires 7d; + add_header Cache-Control "public, no-transform"; + } +} From d05d397548088d8b26bd0a226747f798d5230689 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:35:48 +0000 Subject: [PATCH 06/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20docker-compose.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..52e1c8e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +services: + web: + image: code.paipai.life/frontend/rn-h5 + container_name: rn-h5 + networks: + - app-net + ports: + - "8300:80" + restart: unless-stopped + +networks: + app-net: + external: true \ No newline at end of file From c4f831dbcbbc244adf974e8012b0a2b5df5a33ba Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:36:10 +0000 Subject: [PATCH 07/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20docker-compose-dev.y?= =?UTF-8?q?aml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml => docker-compose-dev.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose.yaml => docker-compose-dev.yaml (100%) diff --git a/docker-compose.yaml b/docker-compose-dev.yaml similarity index 100% rename from docker-compose.yaml rename to docker-compose-dev.yaml From 294c1d6877819e14121a7a19e767a8b2782b988d Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:37:38 +0000 Subject: [PATCH 08/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20docker-compose.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..8ea7b10 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +services: + web: + image: 626064810415.dkr.ecr.us-west-1.amazonaws.com/raveai/rn-h5:${TAG} + container_name: rn-h5 + networks: + - rn-network + ports: + - "8300:80" + restart: unless-stopped + +networks: + rn-network: + external: true \ No newline at end of file From 82d8d119c75c7c7bb49404eeb25bd4f93df50154 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:38:16 +0000 Subject: [PATCH 09/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml index ee62f8c..e12b961 100644 --- a/.gitea/workflows/build-dev.yaml +++ b/.gitea/workflows/build-dev.yaml @@ -38,11 +38,11 @@ jobs: - name: Build Docker image run: | - docker build -t code.paipai.life/backend/rn-outside:latest . + docker build -t code.paipai.life/backend/rn-h5:latest . - name: Push Docker image run: | - docker push code.paipai.life/backend/rn-outside:latest + docker push code.paipai.life/backend/rn-h5:latest env: DOCKER_CONTENT_TRUST: 0 From e641de13e5b05fb0bb336163f3babf71f3dbe48c Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:40:54 +0000 Subject: [PATCH 10/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml index e12b961..7caeffa 100644 --- a/.gitea/workflows/build-dev.yaml +++ b/.gitea/workflows/build-dev.yaml @@ -32,13 +32,13 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: code.paipai.life/backend/rn-outside + images: code.paipai.life/backend/rn-h5 tags: | type=raw,value=latest - name: Build Docker image run: | - docker build -t code.paipai.life/backend/rn-h5:latest . + docker build -f Dockerfile-dev -t code.paipai.life/backend/rn-h5:latest . - name: Push Docker image run: | @@ -63,7 +63,7 @@ jobs: password: ${{ secrets.DEV_SERVER_PASSWORD }} port: 22 source: "docker-compose-dev.yaml" - target: "/home/paipai/data/rn-outside" + target: "/home/paipai/data/rn-h5" override: true - name: Deploy with Docker Compose @@ -75,10 +75,10 @@ jobs: port: 22 script: | # 切换到项目目录 - cd /home/paipai/data/rn-outside + cd /home/paipai/data/rn-h5 # 拉取最新镜像 - docker pull code.paipai.life/backend/rn-outside:latest + docker pull code.paipai.life/backend/rn-h5:latest # 使用 docker-compose 部署 docker compose -f docker-compose-dev.yaml down From 078f0504d493f2d8ea197358a09ed148e9e9a769 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:41:49 +0000 Subject: [PATCH 11/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile-dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-dev | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile-dev diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 0000000..026e4be --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,16 @@ +FROM node:20-alpine AS build + +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm install +COPY . . +RUN npm run build:h5 + + +FROM nginx:stable-alpine AS production + +COPY --from=build /app/dist/build/h5 /usr/share/nginx/html +COPY nginx.dev.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From ef5e8a8b35adfd250a6b0219096b7390fdc3ab2b Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:44:42 +0000 Subject: [PATCH 12/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml index 7caeffa..4ad760b 100644 --- a/.gitea/workflows/build-dev.yaml +++ b/.gitea/workflows/build-dev.yaml @@ -32,17 +32,17 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: code.paipai.life/backend/rn-h5 + images: code.paipai.life/frontend/rn-h5 tags: | type=raw,value=latest - name: Build Docker image run: | - docker build -f Dockerfile-dev -t code.paipai.life/backend/rn-h5:latest . + docker build -f Dockerfile-dev -t code.paipai.life/frontend/rn-h5:latest . - name: Push Docker image run: | - docker push code.paipai.life/backend/rn-h5:latest + docker push code.paipai.life/frontend/rn-h5:latest env: DOCKER_CONTENT_TRUST: 0 @@ -78,7 +78,7 @@ jobs: cd /home/paipai/data/rn-h5 # 拉取最新镜像 - docker pull code.paipai.life/backend/rn-h5:latest + docker pull code.paipai.life/frontend/rn-h5:latest # 使用 docker-compose 部署 docker compose -f docker-compose-dev.yaml down From 4bb67779d6416fbf9903a2db6ab8de59ad4aec17 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 09:49:52 +0000 Subject: [PATCH 13/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.gitea/workflows/bui?= =?UTF-8?q?ld-prod.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-prod.yaml | 111 +++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .gitea/workflows/build-prod.yaml diff --git a/.gitea/workflows/build-prod.yaml b/.gitea/workflows/build-prod.yaml new file mode 100644 index 0000000..30a19f5 --- /dev/null +++ b/.gitea/workflows/build-prod.yaml @@ -0,0 +1,111 @@ +name: rn-h5-prod + +on: + push: + tags: ['v*'] + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + network=host + buildkitd-flags: | + --allow-insecure-entitlement security.insecure + + - name: Log in to container registry + uses: docker/login-action@v3 + with: + registry: 626064810415.dkr.ecr.us-west-1.amazonaws.com + username: ${{ secrets.PROD_DOCKER_USERNAME }} + password: ${{ secrets.PROD_DOCKER_PASSWORD }} + + - name: Extract tag name + id: tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Build Docker image + run: | + docker build -t 626064810415.dkr.ecr.us-west-1.amazonaws.com/raveai/rn-h5:${{ steps.tag.outputs.TAG }} . + + - name: Push Docker image + run: | + docker push 626064810415.dkr.ecr.us-west-1.amazonaws.com/raveai/rn-h5:${{ steps.tag.outputs.TAG }} + env: + DOCKER_CONTENT_TRUST: 0 + + deploy: + runs-on: ubuntu-latest + needs: build-and-push + environment: test + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Extract tag name + id: tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Copy files and deploy via SSH + uses: appleboy/scp-action@v0.1.3 + with: + host: ${{ secrets.PROD_SERVER_HOST }} + username: ${{ secrets.PROD_SERVER_USERNAME }} + key: ${{ secrets.PROD_SERVER_KEY }} + port: 22 + source: "docker-compose.yaml" + target: "/home/ubuntu/docker-compose/rn-h5" + override: true + + - name: Deploy with Docker Compose + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.PROD_SERVER_HOST }} + username: ${{ secrets.PROD_SERVER_USERNAME }} + key: ${{ secrets.PROD_SERVER_KEY }} + port: 22 + script: | + # 切换到项目目录 + cd /home/ubuntu/docker-compose/rn-h5 + + aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin 626064810415.dkr.ecr.us-west-1.amazonaws.com + + # 拉取指定tag的镜像 + docker pull 626064810415.dkr.ecr.us-west-1.amazonaws.com/raveai/rn-h5:${{ steps.tag.outputs.TAG }} + + TAG=${{ steps.tag.outputs.TAG }} docker compose down + TAG=${{ steps.tag.outputs.TAG }} docker compose up -d + + + cleanup: + runs-on: ubuntu-latest + needs: deploy + if: always() + + steps: + - name: Clean up Docker resources on server + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.PROD_SERVER_HOST }} + username: ${{ secrets.PROD_SERVER_USERNAME }} + key: ${{ secrets.PROD_SERVER_KEY }} + port: 22 + script: | + docker image prune -f + docker container prune -f + docker builder prune -f + docker network prune -f + echo "Cleanup completed!" + + - name: Clean up GitHub Actions workspace + run: | + echo "Cleaning up GitHub Actions workspace..." + docker system df \ No newline at end of file From 11ece8872dbea8e64ec3c88867cd100bcd9f3336 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 25 Nov 2025 10:05:31 +0000 Subject: [PATCH 14/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/bui?= =?UTF-8?q?ld-dev.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-dev.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitea/workflows/build-dev.yaml b/.gitea/workflows/build-dev.yaml index 4ad760b..2760728 100644 --- a/.gitea/workflows/build-dev.yaml +++ b/.gitea/workflows/build-dev.yaml @@ -74,13 +74,10 @@ jobs: password: ${{ secrets.DEV_SERVER_PASSWORD }} port: 22 script: | - # 切换到项目目录 cd /home/paipai/data/rn-h5 - # 拉取最新镜像 docker pull code.paipai.life/frontend/rn-h5:latest - # 使用 docker-compose 部署 docker compose -f docker-compose-dev.yaml down docker compose -f docker-compose-dev.yaml up -d