# Stage 1: Build the Go Application FROM golang:1.22-alpine AS builder WORKDIR /app # Initialize go mod if not exists, download deps COPY . . RUN go mod init ai-media-hub || true RUN go mod tidy RUN CGO_ENABLED=0 GOOS=linux go build -o ai-media-hub main.go # Stage 2: Final Image (Python 3.10+ & yt-dlp & Go Binary) FROM python:3.10-slim WORKDIR /app # Install dependencies (ffmpeg for media merging/cropping) RUN apt-get update && \ apt-get install -y ffmpeg curl && \ rm -rf /var/lib/apt/lists/* # Install yt-dlp RUN pip install --no-cache-dir yt-dlp # Copy Go binary and frontend files from builder COPY --from=builder /app/ai-media-hub /app/ai-media-hub COPY --from=builder /app/index.html /app/index.html # Expose port EXPOSE 8000 # Directory for NAS mount RUN mkdir -p /data/nas # Run the Go server CMD ["./ai-media-hub"]