# Multi-stage Dockerfile for LeetCode-Go CLI
FROM golang:tip-alpine3.23 as builder
WORKDIR /src
ENV CGO_ENABLED=0
# Copy the entire repository first to satisfy local module replaces
COPY . .
# Download dependencies (including local replace modules)
RUN go mod download
# Build the ctl CLI into /app/leetcode-go
RUN CGO_ENABLED=0 go build -o /app/leetcode-go ./ctl
FROM alpine:3.23
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=builder /app/leetcode-go ./
ENTRYPOINT ["/app/leetcode-go"]