localhost_oa_front/Dockerfile

30 lines
697 B
Docker
Raw Normal View History

2024-02-27 17:22:27 +08:00
# https://stackoverflow.com/questions/53681522/share-variable-in-multi-stage-dockerfile-arg-before-from-not-substituted
ARG PROJECT_DIR=/huaxin-base-frontend
FROM node:20-slim as builder
ARG PROJECT_DIR
WORKDIR $PROJECT_DIR
# 安装pnpm
RUN npm install -g pnpm
COPY . ./
# 安装依赖
# 若网络不通,可以使用淘宝源
# RUN pnpm config set registry https://registry.npmmirror.com
2024-03-01 16:36:13 +08:00
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
2024-02-27 17:22:27 +08:00
# 构建项目
ENV VITE_BASE_URL=/
RUN pnpm build
FROM nginx:alpine as production
ARG PROJECT_DIR
COPY --from=builder $PROJECT_DIR/dist/ /usr/share/nginx/html
2024-02-28 10:51:39 +08:00
COPY --from=builder $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf
2024-02-27 17:22:27 +08:00
EXPOSE 80