- Introduced a multi-stage build in the Dockerfile to separate build and runtime environments. - Added environment variables for production in the runtime stage. - Updated the start script in package.json to point to the new server entry point.
21 lines
555 B
Docker
21 lines
555 B
Docker
# --- build stage ---
|
|
FROM node:22.12-bullseye AS build
|
|
WORKDIR /app
|
|
COPY package.json yarn.lock ./
|
|
RUN corepack enable && yarn install --frozen-lockfile
|
|
COPY . .
|
|
RUN yarn build
|
|
|
|
# --- runtime stage ---
|
|
FROM node:22.12-bullseye AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production \
|
|
NITRO_HOST=0.0.0.0 \
|
|
NITRO_PORT=3000 \
|
|
HOST=0.0.0.0 \
|
|
PORT=3000
|
|
COPY --from=build /app/.output ./.output
|
|
# (Optional) copy any public/static if you need it at runtime:
|
|
# COPY --from=build /app/public ./public
|
|
EXPOSE 3000
|
|
CMD ["node", ".output/server/index.mjs"]
|