FROM node:16-alpine AS build
WORKDIR /app

# Install TS manually since it's only included in the parent's package.json
RUN npm install --global typescript@^4.5.2
COPY package.json package-lock.json vite.config.ts  ./
RUN npm ci --no-progress --no-optional

COPY tsconfig.json postcss.config.js index.html ./
COPY public public/
COPY src src/

RUN npm run build

FROM nginx:alpine
WORKDIR /app

COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]
