This commit is contained in:
parent
bbb4ad6bd5
commit
7f846922d7
48
.github/workflows/develop.yml
vendored
48
.github/workflows/develop.yml
vendored
@ -12,6 +12,10 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: zuogeus/act-ubuntu:node18
|
||||||
|
options: --add-host nexus.zzwb.cc:192.168.2.7
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environments
|
- name: Setup Environments
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -21,54 +25,54 @@ jobs:
|
|||||||
echo "IMAGE_NAME=${{ vars.REGISTRY_URL }}/${{ vars.REGISTRY_NAMESPACE }}/$REPO:$GITHUB_REF_NAME" >> $GITHUB_ENV
|
echo "IMAGE_NAME=${{ vars.REGISTRY_URL }}/${{ vars.REGISTRY_NAMESPACE }}/$REPO:$GITHUB_REF_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://gitee.com/zuowenbo/checkout@v4.2.2
|
uses: https://gitee.com/zuowenbo/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Get npm cache directory
|
||||||
uses: https://gitee.com/zuowenbo/cache@v4.2.1
|
id: npm-cache-dir
|
||||||
|
shell: bash
|
||||||
|
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
|
||||||
|
|
||||||
|
- name: Set node_modules cache
|
||||||
|
uses: https://gitee.com/zuowenbo/cache@v4.0.0
|
||||||
|
id: npm-cache
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: ${{ steps.npm-cache-dir.outputs.dir }}
|
||||||
key: ${{ runner.os }}-buildx-${{ env.REPO_NAME }}-${{ github.sha }}
|
key: ${{ runner.os }}-node-umi4-${{ hashFiles('**/package-lock.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-${{ env.REPO_NAME }}-
|
${{ runner.os }}-node-umi4-
|
||||||
|
|
||||||
|
- run: npm install --registry=https://registry.npmmirror.com
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: https://gitee.com/zuowenbo/setup-buildx-action@v3.9.0
|
uses: https://gitee.com/zuowenbo/setup-buildx-action@v3.0.0
|
||||||
with:
|
with:
|
||||||
driver-opts: image=registry.cn-shenzhen.aliyuncs.com/zuoge-proxy/buildkit:buildx-stable-1
|
driver-opts: network=host
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: https://gitee.com/zuowenbo/login-action@v3.3.0
|
uses: https://gitee.com/zuowenbo/login-action@v3.0.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ vars.REGISTRY_URL }}
|
registry: ${{ vars.REGISTRY_URL }}
|
||||||
username: ${{ vars.REGISTRY_USERNAME }}
|
username: ${{ vars.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push final image
|
- name: Build and push final image
|
||||||
uses: https://gitee.com/zuowenbo/build-push-action@v6.14.0
|
uses: https://gitee.com/zuowenbo/build-push-action@v5.1.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: ${{ env.IMAGE_NAME }}
|
tags: ${{ env.IMAGE_NAME }}
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
|
||||||
build-args: BRANCH=${{ env.GITHUB_REF_NAME }}
|
build-args: BRANCH=${{ env.GITHUB_REF_NAME }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
||||||
|
|
||||||
- name: Move cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache
|
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
||||||
|
|
||||||
- name: Deploy to remote
|
- name: Deploy to remote
|
||||||
uses: https://gitee.com/zuowenbo/ssh-action@v1.0.3
|
uses: https://gitee.com/zuowenbo/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ vars.DEV_HOST_IP }}
|
host: ${{ vars.LOAN_DEV_HOST_IP }}
|
||||||
port: 22
|
port: 22
|
||||||
username: 'ubuntu'
|
username: 'root'
|
||||||
password: ${{ secrets.DEV_HOST_PASSWORD }}
|
password: ${{ secrets.LOAN_DEV_HOST_PASSWORD }}
|
||||||
script: |
|
script: |
|
||||||
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_URL}}
|
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_URL}}
|
||||||
docker volume create ${{ env.REPO_NAME }} || true
|
|
||||||
docker pull ${{ env.IMAGE_NAME }}
|
docker pull ${{ env.IMAGE_NAME }}
|
||||||
docker stop ${{ env.REPO_NAME }} || true
|
docker stop ${{ env.REPO_NAME }} || true
|
||||||
docker rm ${{ env.REPO_NAME }} || true
|
docker rm ${{ env.REPO_NAME }} || true
|
||||||
|
|||||||
48
.github/workflows/main.yml
vendored
48
.github/workflows/main.yml
vendored
@ -12,6 +12,10 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: zuogeus/act-ubuntu:node18
|
||||||
|
options: --add-host nexus.zzwb.cc:192.168.2.7
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environments
|
- name: Setup Environments
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -21,54 +25,54 @@ jobs:
|
|||||||
echo "IMAGE_NAME=${{ vars.REGISTRY_URL }}/${{ vars.REGISTRY_NAMESPACE }}/$REPO:$GITHUB_REF_NAME" >> $GITHUB_ENV
|
echo "IMAGE_NAME=${{ vars.REGISTRY_URL }}/${{ vars.REGISTRY_NAMESPACE }}/$REPO:$GITHUB_REF_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://gitee.com/zuowenbo/checkout@v4.2.2
|
uses: https://gitee.com/zuowenbo/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Get npm cache directory
|
||||||
uses: https://gitee.com/zuowenbo/cache@v4.2.1
|
id: npm-cache-dir
|
||||||
|
shell: bash
|
||||||
|
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
|
||||||
|
|
||||||
|
- name: Set node_modules cache
|
||||||
|
uses: https://gitee.com/zuowenbo/cache@v4.0.0
|
||||||
|
id: npm-cache
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: ${{ steps.npm-cache-dir.outputs.dir }}
|
||||||
key: ${{ runner.os }}-buildx-${{ env.REPO_NAME }}-${{ github.sha }}
|
key: ${{ runner.os }}-node-umi4-${{ hashFiles('**/package-lock.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-${{ env.REPO_NAME }}-
|
${{ runner.os }}-node-umi4-
|
||||||
|
|
||||||
|
- run: npm install --registry=https://registry.npmmirror.com
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: https://gitee.com/zuowenbo/setup-buildx-action@v3.9.0
|
uses: https://gitee.com/zuowenbo/setup-buildx-action@v3.0.0
|
||||||
with:
|
with:
|
||||||
driver-opts: image=registry.cn-shenzhen.aliyuncs.com/zuoge-proxy/buildkit:buildx-stable-1
|
driver-opts: network=host
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: https://gitee.com/zuowenbo/login-action@v3.3.0
|
uses: https://gitee.com/zuowenbo/login-action@v3.0.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ vars.REGISTRY_URL }}
|
registry: ${{ vars.REGISTRY_URL }}
|
||||||
username: ${{ vars.REGISTRY_USERNAME }}
|
username: ${{ vars.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push final image
|
- name: Build and push final image
|
||||||
uses: https://gitee.com/zuowenbo/build-push-action@v6.14.0
|
uses: https://gitee.com/zuowenbo/build-push-action@v5.1.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: ${{ env.IMAGE_NAME }}
|
tags: ${{ env.IMAGE_NAME }}
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
|
||||||
build-args: BRANCH=${{ env.GITHUB_REF_NAME }}
|
build-args: BRANCH=${{ env.GITHUB_REF_NAME }}
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
||||||
|
|
||||||
- name: Move cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache
|
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
||||||
|
|
||||||
- name: Deploy to remote
|
- name: Deploy to remote
|
||||||
uses: https://gitee.com/zuowenbo/ssh-action@v1.0.3
|
uses: https://gitee.com/zuowenbo/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ vars.MAIN_HOST_IP }}
|
host: ${{ vars.LOAN_MAIN_HOST_IP_PHP }}
|
||||||
port: 22
|
port: 22
|
||||||
username: 'ubuntu'
|
username: 'root'
|
||||||
password: ${{ secrets.MAIN_HOST_PASSWORD }}
|
password: ${{ secrets.LOAN_MAIN_HOST_PASSWORD }}
|
||||||
script: |
|
script: |
|
||||||
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_URL}}
|
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_URL}}
|
||||||
docker volume create ${{ env.REPO_NAME }} || true
|
|
||||||
docker pull ${{ env.IMAGE_NAME }}
|
docker pull ${{ env.IMAGE_NAME }}
|
||||||
docker stop ${{ env.REPO_NAME }} || true
|
docker stop ${{ env.REPO_NAME }} || true
|
||||||
docker rm ${{ env.REPO_NAME }} || true
|
docker rm ${{ env.REPO_NAME }} || true
|
||||||
|
|||||||
18
Dockerfile
18
Dockerfile
@ -1,15 +1,3 @@
|
|||||||
# 构建阶段
|
FROM nexus.zzwb.cc:18444/nginx:1.21-alpine
|
||||||
FROM registry.cn-shenzhen.aliyuncs.com/zuoge-proxy/node:20-alpine AS build
|
COPY dist /usr/share/nginx/html
|
||||||
RUN npm install -g pnpm --registry=https://registry.npmmirror.com
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json pnpm-lock.yaml* ./
|
|
||||||
RUN pnpm install --registry=https://registry.npmmirror.com
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN pnpm build
|
|
||||||
|
|
||||||
# 部署阶段
|
|
||||||
FROM registry.cn-shenzhen.aliyuncs.com/zuoge-proxy/nginx:1.27.3-alpine AS app
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
|
||||||
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
|
||||||
Loading…
x
Reference in New Issue
Block a user