# Stage 1: Build the application
FROM node:20-alpine AS build

WORKDIR /app

COPY package*.json ./
RUN rm -f package-lock.json && npm install \
    && chmod -R +x node_modules/.bin

COPY . .
RUN node node_modules/typescript/bin/tsc -b \
    && node node_modules/vite/bin/vite.js build

# Stage 2: Serve the application with Nginx
FROM nginx:alpine

COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8030

CMD ["nginx", "-g", "daemon off;"]
