2026-05-17 17:24:08 +08:00
|
|
|
|
# =============================================================
|
2026-05-17 19:13:01 +08:00
|
|
|
|
# 积分商城 用户端 H5(uni-app SPA)
|
|
|
|
|
|
# 纯 Nginx 运行时镜像,不含 Node 构建阶段
|
|
|
|
|
|
# 静态文件由宿主机 bind-mount 进来(${SINGLE_H5_DIR}:/usr/share/nginx/html)
|
|
|
|
|
|
# 宿主机目录示例:/www/wwwroot/leilei-jf.czchunfang.com/
|
|
|
|
|
|
# 更新方式:rsync 新 dist 到宿主机目录 → 无需重建镜像
|
2026-05-17 17:24:08 +08:00
|
|
|
|
# =============================================================
|
|
|
|
|
|
|
2026-05-17 19:13:01 +08:00
|
|
|
|
FROM nginx:1.25-alpine
|
2026-05-17 17:24:08 +08:00
|
|
|
|
|
|
|
|
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
|
|
|
2026-05-17 19:13:01 +08:00
|
|
|
|
# 切换阿里云 Alpine 镜像源
|
|
|
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
|
|
|
|
|
&& apk add --no-cache tzdata \
|
|
|
|
|
|
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
|
|
|
|
&& echo $TZ > /etc/timezone \
|
|
|
|
|
|
&& rm -f /etc/apk/cache/*.apk
|
2026-05-17 17:24:08 +08:00
|
|
|
|
|
2026-05-17 19:13:01 +08:00
|
|
|
|
# Nginx 反代配置
|
|
|
|
|
|
# API 请求代理到 single-front-api 容器(Docker 内网,不经宝塔 Nginx)
|
2026-05-17 17:24:08 +08:00
|
|
|
|
RUN cat > /etc/nginx/conf.d/default.conf <<'NGX'
|
|
|
|
|
|
server {
|
|
|
|
|
|
listen 80;
|
|
|
|
|
|
server_name _;
|
|
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
|
|
index index.html;
|
|
|
|
|
|
client_max_body_size 50m;
|
|
|
|
|
|
add_header X-Frame-Options SAMEORIGIN always;
|
|
|
|
|
|
|
|
|
|
|
|
location ~* \.(?:js|css|png|jpg|jpeg|gif|svg|woff2?|ttf|map)$ {
|
|
|
|
|
|
expires 30d;
|
|
|
|
|
|
add_header Cache-Control "public, max-age=2592000, immutable";
|
|
|
|
|
|
try_files $uri =404;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-17 19:13:01 +08:00
|
|
|
|
# 前台 API(单点登录/商品/订单等)
|
2026-05-17 17:24:08 +08:00
|
|
|
|
location /api/ {
|
2026-05-17 19:13:01 +08:00
|
|
|
|
proxy_pass http://single-front-api:30033/api/;
|
2026-05-17 17:24:08 +08:00
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
|
proxy_set_header Host $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 $scheme;
|
|
|
|
|
|
proxy_read_timeout 120s;
|
|
|
|
|
|
client_max_body_size 50m;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
NGX
|
|
|
|
|
|
|
|
|
|
|
|
EXPOSE 80
|