File size: 681 Bytes
95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 77508a8 95b7a25 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # -------- 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"] |