forked from LHRUN/paint-board
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,16 @@ | ||
# 使用 node:18-alpine 构建阶段,并命名为 build-stage | ||
FROM node:18-alpine AS build-stage | ||
|
||
# 设置维护者标签 | ||
FROM node:18-alpine as build-stage | ||
LABEL maintainer="Leo '[email protected]'" | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
COPY . ./ | ||
|
||
# 仅复制 package.json 和 pnpm-lock.yaml 用于依赖安装 | ||
COPY package.json pnpm-lock.yaml ./ | ||
|
||
# 设置 npm 镜像源并安装 pnpm,同时安装项目依赖并构建 | ||
RUN echo "https://registry.npmmirror.com" > .npmrc && \ | ||
npm install -g pnpm && \ | ||
pnpm install --frozen-lockfile && \ | ||
pnpm build && \ | ||
rm .npmrc | ||
pnpm build | ||
|
||
# 复制项目的源文件(为了缩小镜像体积,将此步骤放在依赖安装后) | ||
COPY . . | ||
|
||
# 使用 nginx 的稳定 alpine 版本 | ||
FROM nginx:stable-alpine | ||
|
||
# 将编译后的文件复制到 nginx 的默认静态文件目录 | ||
COPY --from=build-stage /app/dist /usr/share/nginx/html/dist | ||
|
||
# 将自定义 nginx 配置文件复制到 nginx 配置目录 | ||
COPY --from=build-stage /app/nginx.conf /etc/nginx/nginx.conf | ||
|
||
# 暴露端口 80 | ||
EXPOSE 80 | ||
|
||
# 启动 nginx | ||
CMD ["nginx", "-g", "daemon off;"] |