FROM golang:1.21-alpine AS builder

WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build indexer
WORKDIR /app/indexer
RUN CGO_ENABLED=0 GOOS=linux go build -o indexer .

FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

COPY --from=builder /app/indexer/indexer .

CMD ["./indexer"]

