File tree Expand file tree Collapse file tree 4 files changed +83
-25
lines changed
Expand file tree Collapse file tree 4 files changed +83
-25
lines changed Original file line number Diff line number Diff line change 11node_modules
22dist
3+ src-tauri
Original file line number Diff line number Diff line change 1+ # This workflow uses actions that are not certified by GitHub.
2+ # They are provided by a third-party and are governed by
3+ # separate terms of service, privacy policy, and support
4+ # documentation.
5+
6+ name : Publish Docker image
7+
8+ on :
9+ push :
10+ tags :
11+ - ' v*'
12+
13+ jobs :
14+ push_to_registry :
15+ name : Push Docker image to Docker Hub
16+ runs-on : ubuntu-latest
17+ permissions :
18+ packages : write
19+ contents : read
20+ attestations : write
21+ id-token : write
22+ steps :
23+ - name : Check out the repo
24+ uses : actions/checkout@v4
25+
26+ - name : Log in to Docker Hub
27+ uses : docker/login-action@v3
28+ with :
29+ username : ${{ secrets.DOCKER_USERNAME }}
30+ password : ${{ secrets.DOCKER_PASSWORD }}
31+
32+ - name : Extract metadata (tags, labels) for Docker
33+ id : meta
34+ uses : docker/metadata-action@v5
35+ with :
36+ images : log-lottery
37+
38+ - name : Build and push Docker image
39+ id : push
40+ uses : docker/build-push-action@v5
41+ with :
42+ context : .
43+ file : ./Dockerfile
44+ push : true
45+ tags : ${{ steps.meta.outputs.tags }}
46+ labels : ${{ steps.meta.outputs.labels }}
47+
48+ - name : Generate artifact attestation
49+ uses : actions/attest-build-provenance@v1
50+ with :
51+ subject-name : index.docker.io/${{ secrets.DOCKER_USERNAME }}/log-lottery
52+ subject-digest : ${{ steps.push.outputs.digest }}
53+ push-to-registry : true
Original file line number Diff line number Diff line change 11name : Build and Release
22
33on :
4- push :
5- tags :
6- - ' v*'
4+ pull_request :
5+ branches : [main]
76
87jobs :
98 build-and-release :
109 runs-on : ubuntu-latest
11-
10+
1211 permissions :
1312 contents : write
14-
13+
1514 steps :
1615 - name : Checkout code
1716 uses : actions/checkout@v3
2625 - name : Setup Node.js
2726 uses : actions/setup-node@v3
2827 with :
29- node-version : ' 22.x'
30- cache : ' pnpm'
28+ node-version : 22.x
29+ cache : pnpm
3130
3231 - name : Install dependencies
3332 run : pnpm install
5958 dist-file.tar.gz
6059 draft : true
6160 prerelease : false
62- generate_release_notes : true
61+ generate_release_notes : true
Original file line number Diff line number Diff line change 11# 使用官方的 Node 镜像作为基础镜像
2- FROM node:20.12.2
2+ FROM node:22
33
44# 设置工作目录
55WORKDIR /usr/src/app
66
7- # 将本地的 Vite 项目文件复制到工作目录
7+ # 将本地的项目文件复制到工作目录
88COPY . .
99
10- # 安装依赖
11-
10+ # 安装 pnpm
1211RUN npm install pnpm -g
1312
13+ # 安装依赖
1414RUN pnpm install
1515
16- # 执行 Vite 构建命令 ,生成 dist 目录
16+ # 执行构建命令 ,生成 dist 目录
1717RUN pnpm build
1818
1919# 使用 Nginx 镜像作为运行时镜像
2020FROM nginx:1.26
2121
22- # 修改nginx配置
23- # 向 #error_page 前添加内容
24- # location /log-lottery {
25- # alias /usr/share/nginx/log-lottery;
26- # index index.html index.htm;
27- # try_files $uri $uri/ /log-lottery/index.html;
28- # }
29- RUN sed -i 's/#error_page/location \/ log-lottery {\n alias \/ usr\/ share\/ nginx\/ log-lottery;\n index index.html index.htm;\n try_files $uri $uri\/ \/ log-lottery\/ index.html;\n }\n #error_page/' /etc/nginx/conf.d/default.conf
30-
31- # 将 Vite 项目的 dist 目录复制到 Nginx 的默认静态文件目录
32- COPY --from=0 /usr/src/app/dist /usr/share/nginx/log-lottery
22+ # 复制自定义 nginx 配置
23+ COPY --from=0 /usr/src/app/dist /usr/share/nginx/html/log-lottery
24+
25+ # 创建自定义 nginx 配置
26+ RUN echo "server {\
27+ listen 80;\
28+ server_name localhost;\
29+ location / {\
30+ return 301 /log-lottery/;\
31+ }\
32+ location /log-lottery {\
33+ alias /usr/share/nginx/html/log-lottery;\
34+ index index.html index.htm;\
35+ try_files \$ uri \$ uri/ /log-lottery/index.html;\
36+ }\
37+ }" > /etc/nginx/conf.d/default.conf
3338
3439# 暴露容器的 80 端口
3540EXPOSE 80
3641
37- # Nginx 会在容器启动时自动运行,无需手动设置 CMD
42+ # Nginx 会在容器启动时自动运行,无需手动设置 CMD
You can’t perform that action at this time.
0 commit comments