# web-svc — Next.js UI, standalone output
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
COPY services ./services
RUN npm ci
ENV NEXT_TELEMETRY_DISABLED=1
# K8s: rewrites запекаются при сборке, нужен URL api-gateway
ARG API_GATEWAY_URL=http://api-gateway.gooseek:3015
ENV API_GATEWAY_URL=${API_GATEWAY_URL}
RUN npm run build -w web-svc

FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/services/web-svc/public ./services/web-svc/public
COPY --from=builder --chown=nextjs:nodejs /app/services/web-svc/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/services/web-svc/.next/static ./services/web-svc/.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "services/web-svc/server.js"]
