chore: 同步前端仓库最新打包配置与依赖
This commit is contained in:
+23
-5
@@ -1,5 +1,23 @@
|
|||||||
FROM docker.m.daocloud.io/nginx:alpine
|
# 与服务器 deploy.sh 对齐:
|
||||||
# nginx.k8s.conf is rendered by Jenkins from
|
# docker build --build-arg VERSION=$TAG -t sw2/frontend:$TAG .
|
||||||
# .docker-compose/nginx/conf.d/my.conf (envsubst '$KRA_APP').
|
# docker run --rm --add-host sw2-backend:127.0.0.1 sw2/frontend:$TAG nginx -t
|
||||||
COPY nginx.k8s.conf /etc/nginx/conf.d/default.conf
|
# 运行阶段与部署侧 frontend.Dockerfile 一致。本仓库在镜像内编译,
|
||||||
COPY dist /usr/share/nginx/html
|
# 产物对应部署侧的 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
|
||||||
|
|||||||
@@ -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.
@@ -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
@@ -12,7 +12,8 @@
|
|||||||
"test:release": "node --test deploy/release.test.mjs",
|
"test:release": "node --test deploy/release.test.mjs",
|
||||||
"preview": "vite preview --host 0.0.0.0 --mode development",
|
"preview": "vite preview --host 0.0.0.0 --mode development",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix"
|
"lint:fix": "eslint . --fix",
|
||||||
|
"pack:docker": "powershell -NoProfile -ExecutionPolicy Bypass -File ./docker/pack.ps1"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Generated
+347
-352
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user