Files
miti99bot/Dockerfile
T
tiennm99 d62e8a72b3 feat(monkeyd): export monkeydd.com novels as PDF via /monkeyd_crawl
Add the monkeyd module, which crawls a novel and sends the rendered PDF back
as a Telegram document. Crawling and rendering come from the monkeyd-crawler
submodule, resolved through a go.mod replace directive.

The command is admin-only and restricted to monkeydd.com: one run makes
hundreds of outbound requests over minutes, and the extractor only understands
that site. Exports run one at a time and on a detached goroutine, because
handlers are dispatched synchronously and an inline crawl would block every
other command.

The runtime image gains DejaVuSans; font discovery probes system paths and the
distroless base ships none, so PDF rendering would otherwise fail in
production. CI checks out submodules and the builder copies the submodule
go.mod before go mod download, which needs it to resolve the build list.
2026-07-29 23:07:23 +07:00

35 lines
1.3 KiB
Docker

FROM golang:1.26.5-alpine AS builder
WORKDIR /src
# The monkeyd module renders PDFs with an embedded TrueType font, and the
# runtime image below ships no fonts at all. DejaVuSans covers the Latin
# Extended Additional block that Vietnamese diacritics live in; it is installed
# here and copied into the final stage.
RUN apk add --no-cache font-dejavu
# The monkeyd-crawler submodule is resolved through a `replace` directive, so
# its go.mod must be present before `go mod download` can read the build list.
# Only the module files are copied here, keeping this layer cached across
# ordinary source edits.
COPY go.mod go.sum ./
COPY third_party/monkeyd-crawler/go.mod third_party/monkeyd-crawler/go.sum ./third_party/monkeyd-crawler/
RUN go mod download
COPY . .
# The deploy-notify commit SHA comes from Coolify's SOURCE_COMMIT runtime env,
# not from a build arg. Keep it out of the build so Docker cache survives across
# commits. The binary is built plain.
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w" \
-o /out/server \
./cmd/server
FROM gcr.io/distroless/static:nonroot
COPY --from=builder /out/server /server
# pdfout.FindFont() probes system font paths; this is one of the paths it knows.
COPY --from=builder /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf
USER nonroot:nonroot
EXPOSE 8080
ENTRYPOINT ["/server"]