chore: 同步前端仓库最新打包配置与依赖

This commit is contained in:
Yvan
2026-11-05 12:39:50 +08:00
parent c4acb91c27
commit d4233c7139
6 changed files with 452 additions and 358 deletions
+23 -5
View File
@@ -1,5 +1,23 @@
FROM docker.m.daocloud.io/nginx:alpine
# nginx.k8s.conf is rendered by Jenkins from
# .docker-compose/nginx/conf.d/my.conf (envsubst '$KRA_APP').
COPY nginx.k8s.conf /etc/nginx/conf.d/default.conf
COPY dist /usr/share/nginx/html
# 与服务器 deploy.sh 对齐:
# docker build --build-arg VERSION=$TAG -t sw2/frontend:$TAG .
# docker run --rm --add-host sw2-backend:127.0.0.1 sw2/frontend:$TAG nginx -t
# 运行阶段与部署侧 frontend.Dockerfile 一致。本仓库在镜像内编译,
# 产物对应部署侧的 COPY dist/。
FROM docker.m.daocloud.io/library/node:20-alpine AS build
WORKDIR /src
ENV COREPACK_NPM_REGISTRY=https://registry.npmmirror.com
RUN corepack enable && corepack prepare pnpm@9.15.9 --activate
COPY package.json pnpm-lock.yaml ./
RUN pnpm config set registry https://registry.npmmirror.com \
&& pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
FROM docker.m.daocloud.io/nginx:1.28-alpine@sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236
ARG VERSION
LABEL org.opencontainers.image.revision=$VERSION
COPY nginx.sw2.conf /etc/nginx/conf.d/default.conf
COPY --from=build /src/dist /usr/share/nginx/html/
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1/healthz || exit 1
+27
View File
@@ -0,0 +1,27 @@
param(
[Parameter(Position = 0)]
[string]$Tag = (Get-Date -Format 'yyyyMMdd')
)
$ErrorActionPreference = 'Stop'
if ($Tag -notmatch '^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,100}$') {
Write-Error "无效版本号: $Tag"
}
$Root = Split-Path -Parent $PSScriptRoot
$OutDir = $PSScriptRoot
$Image = "sw2/frontend:$Tag"
$Tar = Join-Path $OutDir "sw2-frontend-$Tag.tar"
Write-Host "构建 $Image"
docker build --build-arg "VERSION=$Tag" -t $Image $Root
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
if (Test-Path $Tar) { Remove-Item $Tar -Force }
Write-Host "导出 $Tar"
docker save -o $Tar $Image
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$Item = Get-Item $Tar
Write-Host ("完成 {0} {1:N1} MB" -f $Item.FullName, ($Item.Length / 1MB))
Binary file not shown.
+53
View File
@@ -0,0 +1,53 @@
map $http_upgrade $sw2_connection_upgrade {
default upgrade;
'' close;
}
map $http_x_forwarded_proto $sw2_forwarded_proto {
default $scheme;
http http;
https https;
}
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
server_tokens off;
client_max_body_size 1024m;
location = /healthz {
access_log off;
default_type text/plain;
return 200 'ok';
}
location = /api {
return 308 /api/;
}
location ^~ /api/ {
proxy_pass http://sw2-backend:8000/;
proxy_http_version 1.1;
proxy_set_header Host $http_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 $sw2_forwarded_proto;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $sw2_connection_upgrade;
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
location ~ /\. {
return 404;
}
location / {
add_header Cache-Control 'no-cache';
try_files $uri $uri/ /index.html;
}
}
+2 -1
View File
@@ -12,7 +12,8 @@
"test:release": "node --test deploy/release.test.mjs",
"preview": "vite preview --host 0.0.0.0 --mode development",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint:fix": "eslint . --fix",
"pack:docker": "powershell -NoProfile -ExecutionPolicy Bypass -File ./docker/pack.ps1"
},
"type": "module",
"dependencies": {
+347 -352
View File
File diff suppressed because it is too large Load Diff