refactor(dockerfile): Enhance Docker build process with production configuration
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Restructured Dockerfile to improve dependency installation - Added explicit pnpm installation and project build step - Set NODE_ENV to production for optimized runtime - Simplified source code copying and dependency management
This commit is contained in:
parent
d4265b2855
commit
38553d6a6b
18
Dockerfile
18
Dockerfile
@ -2,16 +2,24 @@ FROM node:18-alpine
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 只复制 package.json,因为可能没有 pnpm-lock.yaml
|
# 复制 package.json
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
|
|
||||||
# 复制所有源代码
|
# 安装 pnpm 和依赖
|
||||||
|
RUN npm install -g pnpm
|
||||||
|
|
||||||
|
# 安装项目依赖
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
|
# 复制源代码
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 安装 pnpm 并初始化项目
|
# 构建项目(如果需要的话)
|
||||||
RUN npm install -g pnpm && \
|
RUN pnpm build
|
||||||
pnpm install
|
|
||||||
|
|
||||||
EXPOSE 8001
|
EXPOSE 8001
|
||||||
|
|
||||||
|
# 使用 production 环境运行
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
CMD ["pnpm", "start"]
|
CMD ["pnpm", "start"]
|
Loading…
Reference in New Issue
Block a user