update dockerfile

This commit is contained in:
DefectingCat
2023-08-14 14:51:33 +08:00
parent 9876964452
commit 07df3240f3

View File

@ -1,5 +1,8 @@
# FROM node:18-alpine AS base
FROM node:lts-alpine AS base
# Install dependencies only when needed # Install dependencies only when needed
FROM node:lts-alpine AS deps FROM base AS deps
WORKDIR /app WORKDIR /app
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
@ -16,7 +19,7 @@ RUN \
fi fi
# Rebuild the source code only when needed # Rebuild the source code only when needed
FROM node:lts-alpine AS builder FROM base AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
@ -61,5 +64,6 @@ USER nextjs
EXPOSE 3000 EXPOSE 3000
ENV PORT 3000 ENV PORT 3000
ENV HOSTNAME localhost
CMD ["node", "server.js"] CMD ["node", "server.js"]