From 804a4f68e8d19e4d522440e3d322fbb7bea84065 Mon Sep 17 00:00:00 2001 From: Latezly Date: Thu, 5 Feb 2026 23:10:14 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=B7=BB=E5=8A=A0Docker=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..950ccb1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# ===== 构建阶段 ===== +FROM node:18-bullseye AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm install --legacy-peer-deps +COPY . . +RUN npx next build +# ===== 运行阶段 ===== +FROM node:18-bullseye AS runner +WORKDIR /app +ENV NODE_ENV=production +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/.next ./.next +EXPOSE 3000 +HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ + CMD wget -qO- http://localhost:3000 || exit 1 +CMD ["npm", "start"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fdb766e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + app: + build: . + ports: + - "3000:3000" + restart: always +