Files
geo/server/Dockerfile
T
root 7f08d92958 feat(browser-fetch): add lightpanda-backed fetch service and knowledge URL fallback
Adds a new browser-fetch microservice that wraps Lightpanda for rendering
JS-heavy pages, and wires it into the knowledge URL parser as a fallback
when the upstream link reader returns 403/429/5xx for an allow-listed
domain (e.g. zhuanlan.zhihu.com). Includes config/env plumbing, hot-reload
diff support, and full deploy assets (Dockerfile target, docker-compose,
k3s manifests, image-build/package scripts).
2026-05-11 11:11:21 +08:00

72 lines
2.5 KiB
Docker

# syntax=docker/dockerfile:1
# ─── Stage 1: Build Go binaries ───────────────────────────────────────────────
FROM golang:1.26.2-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
RUN apk --no-cache add ca-certificates git build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
ARG SERVICE=tenant-api
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 GOOS="${TARGETOS:-$(go env GOOS)}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \
go build -trimpath -ldflags="-s -w" \
-o /bin/service ./cmd/${SERVICE}
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS="${TARGETOS:-$(go env GOOS)}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \
go build -trimpath -ldflags="-s -w" \
-o /bin/browser-fetch ./cmd/browser-fetch
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 GOOS="${TARGETOS:-$(go env GOOS)}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \
go build -trimpath -ldflags="-s -w" \
-o /bin/seed-platform-templates ./cmd/seed-platform-templates
# ─── Stage 2: Migration image (bundles SQL files + migrate binary) ─────────────
FROM migrate/migrate:v4.19.1 AS migrate-tool
FROM alpine:3.19 AS migrate
RUN apk --no-cache add ca-certificates
COPY --from=migrate-tool /usr/local/bin/migrate /usr/local/bin/migrate
COPY --from=builder /bin/seed-platform-templates /usr/local/bin/seed-platform-templates
COPY migrations/ /migrations/
COPY migrations_monitoring/ /migrations_monitoring/
COPY migrations_ops/ /migrations_ops/
COPY configs/ /app/configs/
ENTRYPOINT ["/usr/local/bin/migrate"]
# ─── Stage 3: Runtime image ────────────────────────────────────────────────────
FROM alpine:3.19 AS runtime
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
COPY --from=builder /bin/service /app/service
COPY configs/ /app/configs/
EXPOSE 8080 8081
ENTRYPOINT ["/app/service"]
# ─── Stage 4: Browser fetch runtime (bundles Lightpanda) ──────────────────────
FROM lightpanda/browser:nightly AS browser-fetch
WORKDIR /app
COPY --from=builder /bin/browser-fetch /app/service
EXPOSE 8082
ENTRYPOINT ["/app/service"]