# ── Stage 1: 編譯 ─────────────────────────────────────────────
FROM golang:1.25-alpine AS builder

WORKDIR /build

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o cursor-api-proxy .

# ── Stage 2: 執行環境 ──────────────────────────────────────────
FROM alpine:3.21

RUN apk add --no-cache ca-certificates tzdata

WORKDIR /app

COPY --from=builder /build/cursor-api-proxy .

EXPOSE 8766

ENTRYPOINT ["./cursor-api-proxy"]
