FROM node:20-alpine

WORKDIR /app

# Install system dependencies
RUN apk add --no-cache python3 make g++ git xz && \
    npm install -g gulp-cli http-server

# Prevent Puppeteer from downloading Firefox
ENV PUPPETEER_SKIP_DOWNLOAD=true

# Copy local repo into container
COPY . .

# Install dependencies
RUN npm install

# ⚙️ Build legacy-compatible viewer
RUN npx gulp generic

# Expose server port
EXPOSE 8083

# Serve the legacy viewer build
CMD ["http-server", "", "-p", "8083"]
