16 lines
465 B
Docker
16 lines
465 B
Docker
# 使用 node 构建阶段
|
|
FROM node:22 AS builder
|
|
WORKDIR /app
|
|
COPY . .
|
|
RUN npm install && npm run build
|
|
|
|
# 使用 nginx 作为生产环境
|
|
FROM nginx:stable-alpine
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# 设置静态资源的访问权限,避免 403 Forbidden
|
|
RUN find /usr/share/nginx/html -type f -exec chmod 644 {} \; \
|
|
&& find /usr/share/nginx/html -type d -exec chmod 755 {} \;
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|