Skip to content

Commit 1008aa0

Browse files
committed
feat: 优化 Dockerfile 以提高构建效率,并添加 .npmrc 配置文件
1 parent 6a020fb commit 1008aa0

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

backend/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmjs.org/
2+
legacy-peer-deps=true

backend/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Use a smaller base image
22
FROM node:22.15.0-alpine
33

4-
54
# Install OpenSSL
65
RUN apk add --no-cache openssl
76

87
# Set working directory
98
WORKDIR /app
109

11-
# Copy project files
12-
COPY . .
13-
14-
# Generate Prisma client
15-
RUN npm config set registry https://registry.npmmirror.com/
10+
# Copy package files and npm config first for better caching
11+
COPY package*.json .npmrc ./
1612

13+
# Install dependencies
1714
RUN npm install --omit=dev
1815

16+
# Copy rest of the project files
17+
COPY . .
18+
1919
# Expose container port 3000
2020
EXPOSE 3000
2121

0 commit comments

Comments
 (0)