# Stage 1: Build the Vite application FROM node:20-slim AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Stage 2: Production image FROM node:20-slim RUN apt-get update && apt-get install -y \ chromium \ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # Set the environment to production ENV NODE_ENV production ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true WORKDIR /app # Ensure we have permissions RUN mkdir -p /app/tokens && chown -R node:node /app USER node # Copy only the necessary files for running the app COPY --from=build --chown=node /app/package*.json ./ COPY --from=build --chown=node /app/node_modules ./node_modules COPY --from=build --chown=node /app/dist ./dist COPY --from=build --chown=node /app/server.js ./server.js # Expose the port required by Hugging Face EXPOSE 7860 # The command to start our custom Node.js server CMD ["node", "server.js"]