# -------- Stage 1: Build -------- FROM golang:1.25.4-alpine AS builder # Cài git (cần nếu dùng private modules hoặc go mod download) RUN apk add --no-cache git # Tạo thư mục làm việc WORKDIR /app # Copy go.mod và go.sum trước để cache dependencies COPY go.mod go.sum ./ RUN go mod download # Copy source code COPY . . # Build binary (static) RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app # -------- Stage 2: Run -------- FROM alpine:3.20 WORKDIR /app # Copy binary từ stage builder COPY --from=builder /app/app . # Hugging Face Spaces yêu cầu app chạy trên $PORT ENV PORT=7860 # Expose port EXPOSE 7860 # Run app CMD ["./app"]