# Build Stage
FROM node:18-alpine AS build

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Runtime Stage
FROM node:18-alpine

WORKDIR /app
COPY --from=build /app/dist /app/dist
COPY --from=build /app/package*.json /app/

RUN npm install --production

CMD ["node", "dist/main.js"]