# Build stage
FROM golang:1.24-alpine AS builder

RUN apk add --no-cache git

WORKDIR /src

# Cache module downloads
COPY go.mod go.sum ./
RUN go mod download

# Copy source and build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /gosearch ./cmd/searxng-go

# Runtime stage
FROM alpine:3.21

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

COPY --from=builder /gosearch /usr/local/bin/gosearch
COPY config.example.toml /etc/gosearch/config.example.toml

EXPOSE 8080

ENTRYPOINT ["gosearch"]
CMD ["-config", "/etc/gosearch/config.toml"]
