| # Use Python base image as requested | |
| FROM python:3.12 | |
| # Install curl, unzip (for Bun), and git | |
| RUN apt-get update && apt-get install -y curl unzip git && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 user | |
| # Switch to the non-root user | |
| USER user | |
| # Install Bun globally FOR THE USER | |
| # It will be installed in /home/user/.bun/bin | |
| RUN curl -fsSL https://bun.sh/install | bash | |
| # Set the PATH environment variable AFTER installing Bun | |
| # This ensures subsequent RUN commands find bun | |
| ENV PATH="/home/user/.bun/bin:$PATH" | |
| # Set working directory | |
| WORKDIR /app | |
| # Clone the repository into the working directory | |
| # Git clone will run as 'user' | |
| RUN git clone https://github.com/amirkabiri/duckai.git . | |
| # Install production dependencies using Bun | |
| # This should now find bun in the PATH set by ENV | |
| RUN bun install --frozen-lockfile --production | |
| # Set environment variables for Hugging Face Spaces | |
| ENV HOST=0.0.0.0 | |
| ENV PORT=7860 | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["bun", "run", "src/server.ts"] | |