FROM node:22-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci

FROM deps AS ci
COPY . .
RUN npm run lint
RUN npm run build

FROM deps AS build
COPY . .
RUN npm run build

FROM nginx:1.27-alpine
RUN sed -i 's#error_log /var/log/nginx/error.log notice;#error_log /var/log/nginx/error.log warn;#' /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
