运维脚本调整

This commit is contained in:
2026-07-02 11:56:28 +08:00
parent 3ae35e925a
commit c10b446c23
5 changed files with 186 additions and 22 deletions
+35
View File
@@ -0,0 +1,35 @@
# ========== 构建前端 ==========
FROM docker.m.daocloud.io/node:18-alpine AS builder
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
WORKDIR /app
COPY package*.json ./
RUN npm install --registry=https://registry.npmmirror.com
COPY . .
RUN npm run build
# ========== 部署到 Nginx ==========
FROM docker.m.daocloud.io/nginx:alpine
COPY --from=builder /app/dist/ /usr/share/nginx/html/
COPY ngnix.conf /etc/nginx/conf.d/default.conf
COPY ssl/ /etc/nginx/ssl/
RUN printf '%s\n' \
'#!/bin/sh' \
'set -e' \
'if [ -n "$API_HOST" ]; then' \
' HOST_IP="$API_HOST"' \
'else' \
' HOST_IP=$(route -n 2>/dev/null | grep "^0.0.0.0" | tr -s " " | cut -d " " -f2)' \
'fi' \
'sed -i "s/__API_HOST__/$HOST_IP/g" /etc/nginx/conf.d/default.conf' \
> /docker-entrypoint.d/01-set-api-host.sh && chmod +x /docker-entrypoint.d/01-set-api-host.sh
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]