FROM golang:1.25-alpine AS source


WORKDIR /src

RUN apk add --no-cache ca-certificates git ffmpeg poppler-utils 7zip xz

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

COPY . .

FROM source AS test
# Test packages create independent SQLite stores. Serialize packages to avoid
# concurrent server/store initialization exhausting the shared runner's I/O.
# Keep production database deadlines and the complete test suite unchanged.
RUN go test -p 1 ./...

FROM source AS runtime
RUN go build -o /pageswiki ./cmd/pageswiki

EXPOSE 8081

CMD ["/pageswiki"]
