Merge branch 'main' into dev
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
src-tauri
|
||||||
56
.github/workflows/docker.yml
vendored
Normal file
56
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
name: Publish Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
name: Push Docker image to Docker Hub
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ secrets.DOCKER_USERNAME }}/log-lottery
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v1
|
||||||
|
with:
|
||||||
|
subject-name: index.docker.io/${{ secrets.DOCKER_USERNAME }}/log-lottery
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -8,6 +8,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-web:
|
build-web:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
|||||||
35
Dockerfile
35
Dockerfile
@@ -4,34 +4,39 @@ FROM node:22-alpine as builder
|
|||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# 将本地的 Vite 项目文件复制到工作目录
|
# 将本地的项目文件复制到工作目录
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 安装依赖
|
# 安装 pnpm
|
||||||
|
|
||||||
RUN npm install pnpm -g
|
RUN npm install pnpm -g
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
RUN pnpm install
|
RUN pnpm install
|
||||||
|
|
||||||
# 执行 Vite 构建命令,生成 dist 目录
|
# 执行构建命令,生成 dist 目录
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
# 使用 Nginx 镜像作为运行时镜像
|
# 使用 Nginx 镜像作为运行时镜像
|
||||||
FROM nginx:1.26
|
FROM nginx:1.26
|
||||||
|
|
||||||
# 修改nginx配置
|
# 复制自定义 nginx 配置
|
||||||
# 向 #error_page 前添加内容
|
COPY --from=0 /usr/src/app/dist /usr/share/nginx/html/log-lottery
|
||||||
# location /log-lottery {
|
|
||||||
# alias /usr/share/nginx/log-lottery;
|
|
||||||
# index index.html index.htm;
|
|
||||||
# try_files $uri $uri/ /log-lottery/index.html;
|
|
||||||
# }
|
|
||||||
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
|
|
||||||
|
|
||||||
# 将 Vite 项目的 dist 目录复制到 Nginx 的默认静态文件目录
|
# 创建自定义 nginx 配置
|
||||||
COPY --from=0 /usr/src/app/dist /usr/share/nginx/log-lottery
|
RUN echo "server {\
|
||||||
|
listen 80;\
|
||||||
|
server_name localhost;\
|
||||||
|
location / {\
|
||||||
|
return 301 /log-lottery/;\
|
||||||
|
}\
|
||||||
|
location /log-lottery {\
|
||||||
|
alias /usr/share/nginx/html/log-lottery;\
|
||||||
|
index index.html index.htm;\
|
||||||
|
try_files \$uri \$uri/ /log-lottery/index.html;\
|
||||||
|
}\
|
||||||
|
}" > /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# 暴露容器的 80 端口
|
# 暴露容器的 80 端口
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# Nginx 会在容器启动时自动运行,无需手动设置 CMD
|
# Nginx 会在容器启动时自动运行,无需手动设置 CMD
|
||||||
Reference in New Issue
Block a user