From cc330a8d8c36e8171d0935bbea158c8eeb8fab19 Mon Sep 17 00:00:00 2001 From: ywp Date: Sat, 14 Jun 2025 16:19:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b98eb3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# 构建阶段 +FROM node:16 AS builder + +WORKDIR /app + +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile + +COPY . . + +# 执行构建 +RUN yarn && yarn build + +# 生产阶段(使用 Nginx 只部署静态文件) +FROM nginx:stable-alpine + +# 清空默认目录 +RUN rm -rf /usr/share/nginx/html/* + +# 复制构建产物到 Nginx 目录 +COPY --from=builder /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file