# Stage 1: Build Go Server FROM golang:1.21-alpine AS builder WORKDIR /app # Copy both go.mod and main.go immediately # We need the code to generate the go.sum file automatically COPY go.mod main.go ./ # Generate go.sum and download dependencies RUN go mod tidy # Build the binary RUN go build -o server main.go # Stage 2: Runtime Environment (Python + Go Binary) FROM python:3.10-slim WORKDIR /app # Install git and system deps RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/* # Install Hugging Face CLI RUN pip install --no-cache-dir huggingface_hub # Copy binary from builder stage COPY --from=builder /app/server . # Create download directory RUN mkdir -p /app/downloads # Expose Hugging Face Space Port EXPOSE 7860 CMD ["./server"]