# Use official Bun image FROM oven/bun:1-alpine AS base # Set working directory and ensure bun user owns it WORKDIR /home/bun/app # Copy package files first for better caching (as root for now) COPY package.json bun.lockb ./ # Install dependencies as root (to avoid permission issues) RUN bun install --frozen-lockfile --production # Copy application files COPY . . # Change ownership to bun user (UID 1000 for HF Spaces) RUN chown -R bun:bun /home/bun/app # Switch to bun user USER bun # Expose port 7860 (Hugging Face Spaces default) EXPOSE 7860 # Set default port for Hugging Face Spaces ENV PORT=7860 # Run the server CMD ["bun", "server.ts"]