File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -3,23 +3,22 @@ FROM node:24-alpine
33WORKDIR /app
44ENV NODE_ENV=production
55
6- # 1. 在一个干净的目录下只安装 sharp
7- # 这样 npm 不会去扫描项目的 package.json,也就不会有依赖冲突
6+ # 1. 独立安装 sharp
87RUN mkdir -p /app/sharp-install && \
98 cd /app/sharp-install && \
109 npm install sharp --os=linux --libc=musl --cpu=arm64
1110
12- # 2. 拷贝 Next.js 产物到 /app
11+ # 2. 拷贝 Next.js 产物
1312COPY .next/standalone ./
1413COPY .next/static ./.next/static
1514COPY public ./public
1615
17- # 3. 将安装好的 sharp 移动到正确的位置
18- # 或者直接设置路径指向它
19- RUN mkdir -p node_modules && \
16+ # 3. 确保目标目录干净,并拷贝 sharp
17+ RUN rm -rf ./node_modules/sharp && \
18+ mkdir -p ./ node_modules && \
2019 cp -r /app/sharp-install/node_modules/sharp ./node_modules/
2120
22- # 4. 强制 Next.js 使用这个特定的 sharp
21+ # 4. 指向 sharp 路径
2322ENV NEXT_SHARP_PATH=/app/node_modules/sharp
2423
2524EXPOSE 3000
You can’t perform that action at this time.
0 commit comments