feat: 优化部署配置
parent
7bea445253
commit
7f02e3bc97
|
|
@ -32,7 +32,7 @@ env:
|
||||||
# 部署服务器密码, 例如: 123456
|
# 部署服务器密码, 例如: 123456
|
||||||
deploy_pass: ${{ secrets.DEPLOY_PASS }}
|
deploy_pass: ${{ secrets.DEPLOY_PASS }}
|
||||||
# 要更新的 docker 服务名称, 例如: demo_web
|
# 要更新的 docker 服务名称, 例如: demo_web
|
||||||
deploy_name: demo_web
|
deploy_name: appnify_web
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -42,43 +42,40 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
id: checkout
|
id: checkout
|
||||||
uses: https://git.dev.juetan.cn/mirror/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: 设置环境
|
# - name: 设置NodeJS环境
|
||||||
uses: https://git.dev.juetan.cn/mirror/setup-node@v2
|
# uses: actions/setup-node@v2
|
||||||
|
|
||||||
- name: 安装依赖
|
# - name: 安装Npm依赖
|
||||||
run: |
|
# run: npm install --registry https://registry.npmmirror.com/
|
||||||
npm install --registry https://registry.npmmirror.com/
|
|
||||||
|
|
||||||
- name: 构建产物
|
# - name: 构建产物
|
||||||
run: npm run build
|
# run: npm run build
|
||||||
|
|
||||||
- name: 打印目录
|
# - name: 打印产物目录
|
||||||
run: ls ./dist
|
# run: ls ./dist
|
||||||
|
|
||||||
- name: 构建镜像
|
- name: 构建Docker镜像
|
||||||
run: |
|
run: docker build -t ${{ env.docker_name }}:latest .
|
||||||
docker build -t ${{ env.docker_name }}:latest .
|
|
||||||
|
|
||||||
- name: 登陆镜像
|
- name: 登陆Docker镜像仓库
|
||||||
run: |
|
run: docker login -u "${{ env.docker_user }}" -p "${{ env.docker_pass }}" ${{ env.docker_host }}
|
||||||
docker login -u "${{ env.docker_user }}" -p "${{ env.docker_pass }}" ${{ env.docker_host }}
|
|
||||||
|
|
||||||
- name: 推送镜像
|
- name: 推送Docker镜像到仓库
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: docker push ${{ env.docker_name }}:latest
|
||||||
docker push ${{ env.docker_name }}:latest
|
|
||||||
|
|
||||||
- name: 标记镜像
|
- name: 打上Docker镜像版本标签并推送到仓库
|
||||||
if: gitea.ref_type == 'tag'
|
if: gitea.ref_type == 'tag'
|
||||||
run: |
|
run: |
|
||||||
echo "当前推送版本:${{ gitea.ref_name }}"
|
echo "当前推送版本:${{ gitea.ref_name }}"
|
||||||
docker tag ${{ env.docker_name }}:latest ${{ env.docker_name }}:${{ gitea.ref_name }}
|
docker tag ${{ env.docker_name }}:latest ${{ env.docker_name }}:${{ gitea.ref_name }}
|
||||||
docker push ${{ env.docker_name }}:${{ gitea.ref_name }}
|
docker push ${{ env.docker_name }}:${{ gitea.ref_name }}
|
||||||
|
|
||||||
- name: 更新服务
|
- name: 登陆到部署环境执行更新命令
|
||||||
uses: https://git.dev.juetan.cn/mirror/ssh-action@v1.0.0
|
uses: appleboy/ssh-action@v1.0.0
|
||||||
|
if: false
|
||||||
with:
|
with:
|
||||||
host: ${{ env.deploy_host }}
|
host: ${{ env.deploy_host }}
|
||||||
port: ${{ env.deploy_port }}
|
port: ${{ env.deploy_port }}
|
||||||
|
|
|
||||||
13
Dockerfile
13
Dockerfile
|
|
@ -1,15 +1,16 @@
|
||||||
FROM node:20-alpine as build
|
FROM node:20-alpine as builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./package.json .
|
COPY package.json .
|
||||||
COPY ./pnpm-lock.yaml .
|
COPY pnpm-lock.yaml .
|
||||||
|
COPY .npmrc .
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
RUN pnpm install --registry https://registry.npmmirror.com/
|
RUN pnpm install
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
COPY --from=build /app/.github/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY --from=builder /app/.github/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
Loading…
Reference in New Issue