build(Dockerfile): 将构建工具从 npm 更改为 pnpm
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
- 安装全局 pnpm - 配置 pnpm 使用国内镜像源 - 使用 pnpm 替代 npm 安装依赖和构建项目
This commit is contained in:
parent
451f0a44e6
commit
9d7dcd7acc
15
Dockerfile
15
Dockerfile
@ -3,8 +3,8 @@ FROM node:22-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 配置alpine国内镜像加速
|
||||
RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories
|
||||
# # 配置alpine国内镜像加速
|
||||
# RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories
|
||||
|
||||
# 安装tzdata,默认的alpine基础镜像不包含时区组件,安装后可通过TZ环境变量配置时区
|
||||
RUN apk add --no-cache tzdata
|
||||
@ -17,14 +17,19 @@ RUN npm config set registry https://registry.npmmirror.com
|
||||
|
||||
# 安装开发期依赖
|
||||
COPY package.json ./package.json
|
||||
RUN npm install
|
||||
|
||||
RUN npm install -g pnpm
|
||||
|
||||
RUN pnpm config set registry https://registry.npmmirror.com
|
||||
|
||||
RUN pnpm install
|
||||
# 构建项目
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
RUN pnpm run build
|
||||
# 删除开发期依赖
|
||||
RUN rm -rf node_modules && rm package-lock.json
|
||||
# 安装生产环境依赖
|
||||
RUN npm install --production
|
||||
RUN pnpm install --production
|
||||
|
||||
# 如果端口更换,这边可以更新一下
|
||||
EXPOSE 8001
|
||||
|
Loading…
Reference in New Issue
Block a user