FROM node:20-alpine AS deps WORKDIR /app RUN apk add --no-cache libc6-compat COPY package.json package-lock.json* ./ RUN npm install --no-audit --no-fund FROM node:20-alpine AS build WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build FROM node:20-alpine AS runtime ENV NODE_ENV=production \ NITRO_HOST=0.0.0.0 \ NITRO_PORT=3000 WORKDIR /app # node:20-alpine ships a `node` user at uid/gid 1000 already. COPY --from=build --chown=node:node /app/.output ./.output # Workaround for Nitro 2.12.4: the public-asset manifest declares paths # relative to .output/server/, but the runtime resolves them relative to # .output/server/chunks/nitro/, so it looks under chunks/public/. Symlink # that location to the real public dir so `node .output/server/index.mjs` # can actually find _nuxt/*.css and *.js. RUN ln -sfn ../../public /app/.output/server/chunks/public USER node EXPOSE 3000 CMD ["node", ".output/server/index.mjs"]