FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
ENV NEXT_PUBLIC_API_URL=https://clube67.com/api
RUN npm run build

FROM node:20-alpine AS runner
WORKDIR /app
COPY package*.json ./
# Instala produção + typescript/@types/node (necessários para next dev)
RUN npm ci --omit=dev && npm install --no-save typescript @types/node && npm cache clean --force
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.mjs ./next.config.mjs

EXPOSE 3003
ENV PORT=3003
ENV NODE_ENV=production
CMD ["npm", "run", "start"]
