# Use node 22 slim for both build and runtime FROM node:22-slim # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ git curl bash python3 make g++ ca-certificates openssh-client jq \ # Playwright/Chromium dependencies libglib2.0-0 libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 \ libcups2 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 \ libxfixes3 libxrandr2 libgbm1 libasound2 libpango-1-0-0 libcairo2 \ libx11-6 libx11-xcb1 libxcb1 libxext6 libxrender1 libxss1 libxtst6 \ libxshmfence1 libgtk-3-0 libexpat1 libfontconfig1 fonts-liberation \ xdg-utils libpangocairo-1.0-0 libpangoft2-1.0-0 libu2f-udev libvulkan1 \ && rm -rf /var/lib/apt/lists/* # Install GitHub CLI RUN GH_VERSION="2.63.2" \ && ARCH=$(uname -m) \ && case "$ARCH" in \ x86_64) GH_ARCH="amd64" ;; \ aarch64|arm64) GH_ARCH="arm64" ;; \ *) echo "Unsupported architecture: $ARCH" && exit 1 ;; \ esac \ && curl -L "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${GH_ARCH}.tar.gz" -o gh.tar.gz \ && tar -xzf gh.tar.gz \ && mv gh_${GH_VERSION}_linux_${GH_ARCH}/bin/gh /usr/local/bin/gh \ && rm -rf gh.tar.gz gh_${GH_VERSION}_linux_${GH_ARCH} # Set working directory WORKDIR /app # Copy all files from the current context COPY . . # Set environment variables for the build ENV NODE_ENV=production ENV VITE_SKIP_ELECTRON=true # Install all dependencies (including dev deps for build) RUN npm ci --ignore-scripts && npm rebuild node-pty # Build shared libraries, frontend, and backend RUN npm run build:packages && \ npm run build --workspace=apps/ui && \ npm run build --workspace=apps/server # Install Playwright Chromium RUN npx playwright install chromium # Create data directory and set permissions RUN mkdir -p /app/data && chmod 777 /app/data # Environment variables for runtime ENV PORT=7860 ENV DATA_DIR=/app/data ENV PATH="/home/node/.local/bin:${PATH}" # Expose the Hugging Face Spaces port EXPOSE 7860 # Copy settings update script COPY update_settings.py /usr/local/bin/update_settings.py RUN chmod +x /usr/local/bin/update_settings.py # Use a custom entrypoint script to handle secrets and start the app RUN chmod +x entrypoint.sh CMD ["./entrypoint.sh"]