File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1- FROM node:22.18.0-alpine3.22 AS build
1+ # syntax=docker/dockerfile:1.7
2+ FROM --platform=$BUILDPLATFORM node:22.18.0-alpine3.22 AS build
23WORKDIR /app
4+
5+ # 若依赖含原生扩展,可加编译工具(按需启用)
6+ # RUN apk add --no-cache --virtual .build-deps python3 make g++
7+
8+ # Node 22 使用 Corepack 管理 Yarn
9+ RUN apk add --no-cache libc6-compat && corepack enable && corepack prepare yarn@stable --activate
10+
11+ # 先拷贝依赖清单,利用缓存
12+ COPY package.json yarn.lock ./
13+ RUN yarn --version && node -v && yarn install --immutable
14+
15+ # 再拷贝源码并构建
316COPY . .
4- RUN yarn install
517RUN yarn build
618
7- FROM nginx:1.24-alpine
19+ FROM --platform=$TARGETPLATFORM nginx:1.24-alpine
820COPY --from=build /app/dist /usr/share/nginx/html
921EXPOSE 80
10- CMD [ "nginx" , "-g" , "daemon off;" ]
22+ CMD ["nginx" , "-g" , "daemon off;" ]
You can’t perform that action at this time.
0 commit comments