Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
FROM node:14-alpine AS builder
# 定义变量,用来选择 yarn/pnpm ,默认为 yarn
ARG TARGET=yarn

# Yarn build
FROM node:14-alpine AS yarn-build
WORKDIR /app
COPY . /app
RUN yarn install && yarn build

# Pnpm build
FROM node:20-slim AS pnpm-base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY . /app


FROM pnpm-base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM pnpm-base AS pnpm-build
# 高版本 node 兼容
ENV NODE_OPTIONS --openssl-legacy-provider
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

# 通过传递的变量决定最终 build
FROM ${TARGET}-build as builder

FROM nginx:stable-alpine
COPY --from=builder /app/build /usr/share/nginx/html
EXPOSE 80
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
"typescript": "^4.0.3",
"url-loader": "4.1.1",
"web-vitals": "^0.2.4",
"webpack": "4.44.2",
Expand Down Expand Up @@ -180,9 +179,11 @@
"@types/markdown-it-emoji": "^2.0.0",
"@types/react-color": "^3.0.4",
"babel-plugin-import": "^1.13.3",
"codemirror": "5.62.3",
"gulp": "^4.0.2",
"gulp-less": "^4.0.1",
"less": "^3.13.1",
"less-loader": "5.0.0"
"less-loader": "5.0.0",
"typescript": "4.0.3"
}
}
Loading