FROM debian:bullseye-slim

ENV DEBIAN_FRONTEND="noninteractive"

RUN apt-get update && apt-get -y upgrade \
    && apt-get -y install \
      curl nodejs npm \
    && npm install -g vue vite n \
    && n stable \
    && mkdir /app \
    && rm -rf /var/lib/apt/lists/* /usr/share/man/* /usr/share/doc/*

WORKDIR /app

COPY ./public public
COPY ./src src
COPY ./config.prod.js ./config.js
COPY ./index.html .
COPY ./package.json .
COPY ./package-lock.json .
COPY ./postcss.config.js .
COPY ./tailwind.config.js .
COPY ./vite.config.js .

RUN npm install && npm run build

FROM nginx
COPY --from=0 /app/dist /usr/share/nginx/html
COPY ./nginx/conf /etc/nginx/conf.d/