38 lines
673 B
Docker
38 lines
673 B
Docker
# base node image
|
|
FROM node:18-bullseye-slim as base
|
|
|
|
# set for base and all layer that inherit from it
|
|
ENV NODE_ENV production
|
|
|
|
# Setup production node_modules
|
|
FROM base as deps
|
|
|
|
WORKDIR /app
|
|
|
|
ADD package.json ./
|
|
RUN npm install
|
|
|
|
# Build the app
|
|
FROM base as build
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Finally, build the production image with minimal footprint
|
|
FROM base as production
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=build /app/package.json ./package.json
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
EXPOSE 3000
|
|
CMD node ./dist/server/entry.mjs
|