build(GOV-009): 对齐应用部署与运行入口
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
FROM node:22.22.0-bookworm-slim AS builder
|
||||
|
||||
ENV PNPM_HOME=/pnpm
|
||||
ENV PATH=$PNPM_HOME:$PATH
|
||||
RUN corepack enable && corepack prepare pnpm@10.25.0 --activate
|
||||
|
||||
WORKDIR /workspace
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
COPY web/package.json web/package.json
|
||||
COPY server/package.json server/package.json
|
||||
RUN pnpm install --frozen-lockfile --filter @a-share-analysis/web...
|
||||
|
||||
COPY web web
|
||||
ARG VITE_APP_ENV=production
|
||||
ARG VITE_APP_TITLE=A-Share-Analysis
|
||||
ARG VITE_API_BASE_URL=
|
||||
ARG VITE_ENABLE_DEVTOOLS=false
|
||||
ENV NODE_ENV=production
|
||||
ENV VITE_APP_ENV=$VITE_APP_ENV
|
||||
ENV VITE_APP_TITLE=$VITE_APP_TITLE
|
||||
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
|
||||
ENV VITE_ENABLE_DEVTOOLS=$VITE_ENABLE_DEVTOOLS
|
||||
RUN pnpm --filter @a-share-analysis/web build
|
||||
|
||||
FROM nginx:1.28.2-alpine3.23
|
||||
COPY web/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder /workspace/web/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1
|
||||
@@ -0,0 +1,20 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:3000;
|
||||
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;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user