2025-08-05 07:08:07 +00:00
|
|
|
# Build stage
|
chore: bump Go to 1.26 and slim docreader dependencies
- Bump base image in docker/Dockerfile.app from golang:1.24 to golang:1.26
to match `go 1.26` declared in go.mod (fixes CI build failure on
`go mod download`).
- Drop unused docreader components and their dependencies:
- Remove `docreader/ocr/` package (paddle/vlm/dummy backends are
unreferenced by the main flow; OCR/VLM is handled by the Go App).
- Remove `docreader/parser/storage.py` (dead code; image persistence
happens in the Go App via inline ImageRef bytes).
- Remove `docreader/scripts/download_deps.py` (PaddleOCR pre-download).
- Drop deps: paddleocr, paddlepaddle, openai, ollama, minio,
cos-python-sdk-v5, oss2, asyncio, pypdf2, markdown, mistletoe,
goose3, markdownify, pdfplumber, antiword, urllib3.
- Re-lock uv.lock: 145 -> 79 packages.
- Update docreader/README.md to reflect that OCR/VLM/storage are no
longer configured at the docreader level.
2026-05-09 05:31:54 +00:00
|
|
|
FROM golang:1.26-bookworm AS builder
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# 通过构建参数接收敏感信息
|
|
|
|
|
ARG GOPRIVATE_ARG
|
|
|
|
|
ARG GOPROXY_ARG
|
|
|
|
|
ARG GOSUMDB_ARG=off
|
2025-12-29 13:01:58 +00:00
|
|
|
ARG APK_MIRROR_ARG
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
# 设置Go环境变量
|
|
|
|
|
ENV GOPRIVATE=${GOPRIVATE_ARG}
|
|
|
|
|
ENV GOPROXY=${GOPROXY_ARG}
|
|
|
|
|
ENV GOSUMDB=${GOSUMDB_ARG}
|
|
|
|
|
|
2025-09-18 06:40:07 +00:00
|
|
|
# Install dependencies
|
2025-11-13 12:01:04 +00:00
|
|
|
RUN if [ -n "$APK_MIRROR_ARG" ]; then \
|
2025-12-23 08:56:30 +00:00
|
|
|
sed -i "s@deb.debian.org@${APK_MIRROR_ARG}@g" /etc/apt/sources.list.d/debian.sources; \
|
2025-11-13 12:01:04 +00:00
|
|
|
fi && \
|
2025-12-23 08:56:30 +00:00
|
|
|
apt-get update && \
|
2026-02-28 09:39:59 +00:00
|
|
|
apt-get install -y git build-essential libsqlite3-dev
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
# Install migrate tool
|
|
|
|
|
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
|
|
|
|
|
|
2025-09-18 06:40:07 +00:00
|
|
|
# Copy go mod and sum files
|
2025-09-18 09:23:05 +00:00
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
2026-02-10 04:15:21 +00:00
|
|
|
COPY cmd/download cmd/download
|
|
|
|
|
RUN go run cmd/download/duckdb/duckdb.go
|
2025-09-18 09:26:02 +00:00
|
|
|
COPY . .
|
2025-08-05 07:08:07 +00:00
|
|
|
|
2025-09-17 08:02:08 +00:00
|
|
|
# Get version and commit info for build injection
|
|
|
|
|
ARG VERSION_ARG
|
|
|
|
|
ARG COMMIT_ID_ARG
|
|
|
|
|
ARG BUILD_TIME_ARG
|
|
|
|
|
ARG GO_VERSION_ARG
|
|
|
|
|
|
|
|
|
|
# Set build-time variables
|
|
|
|
|
ENV VERSION=${VERSION_ARG}
|
|
|
|
|
ENV COMMIT_ID=${COMMIT_ID_ARG}
|
|
|
|
|
ENV BUILD_TIME=${BUILD_TIME_ARG}
|
|
|
|
|
ENV GO_VERSION=${GO_VERSION_ARG}
|
|
|
|
|
|
|
|
|
|
# Build the application with version info
|
2025-09-18 09:23:05 +00:00
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod make build-prod
|
2025-09-18 11:53:18 +00:00
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod cp -r /go/pkg/mod/github.com/yanyiwu/ /app/yanyiwu/
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
# Final stage
|
2025-12-23 08:56:30 +00:00
|
|
|
FROM debian:12.12-slim
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2025-12-29 13:01:58 +00:00
|
|
|
ARG APK_MIRROR_ARG
|
2025-11-13 12:01:04 +00:00
|
|
|
|
2025-12-15 11:13:58 +00:00
|
|
|
# Create a non-root user first
|
2025-12-23 08:56:30 +00:00
|
|
|
RUN useradd -m -s /bin/bash appuser
|
2025-12-15 11:13:58 +00:00
|
|
|
|
2026-04-21 01:44:04 +00:00
|
|
|
# First, install ca-certificates without mirror to ensure HTTPS works
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
|
apt-get install -y --no-install-recommends ca-certificates && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Then switch to mirror if specified and install other packages
|
2025-11-13 12:01:04 +00:00
|
|
|
RUN if [ -n "$APK_MIRROR_ARG" ]; then \
|
2025-12-23 08:56:30 +00:00
|
|
|
sed -i "s@deb.debian.org@${APK_MIRROR_ARG}@g" /etc/apt/sources.list.d/debian.sources; \
|
2025-11-13 12:01:04 +00:00
|
|
|
fi && \
|
2025-12-29 12:39:20 +00:00
|
|
|
apt-get update && \
|
2025-12-23 08:56:30 +00:00
|
|
|
apt-get install -y --no-install-recommends \
|
2026-04-21 01:44:04 +00:00
|
|
|
build-essential postgresql-client default-mysql-client tzdata sed curl bash vim wget \
|
2026-02-28 09:39:59 +00:00
|
|
|
libsqlite3-0 \
|
2025-12-23 08:56:30 +00:00
|
|
|
python3 python3-pip python3-dev libffi-dev libssl-dev \
|
2026-03-05 03:53:17 +00:00
|
|
|
nodejs npm \
|
2026-04-09 14:40:41 +00:00
|
|
|
gosu \
|
|
|
|
|
ffmpeg && \
|
2025-12-12 12:24:29 +00:00
|
|
|
python3 -m pip install --break-system-packages --upgrade pip setuptools wheel && \
|
2025-12-15 11:13:58 +00:00
|
|
|
mkdir -p /home/appuser/.local/bin && \
|
|
|
|
|
curl -LsSf https://astral.sh/uv/install.sh | CARGO_HOME=/home/appuser/.cargo UV_INSTALL_DIR=/home/appuser/.local/bin sh && \
|
|
|
|
|
chown -R appuser:appuser /home/appuser && \
|
|
|
|
|
ln -sf /home/appuser/.local/bin/uvx /usr/local/bin/uvx && \
|
2025-12-23 08:56:30 +00:00
|
|
|
chmod +x /usr/local/bin/uvx && \
|
|
|
|
|
apt-get clean && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
2025-12-15 11:13:58 +00:00
|
|
|
|
|
|
|
|
# Create data directories and set permissions
|
2025-09-18 06:40:07 +00:00
|
|
|
RUN mkdir -p /data/files && \
|
2025-09-18 06:40:07 +00:00
|
|
|
chown -R appuser:appuser /app /data/files
|
|
|
|
|
|
|
|
|
|
# Copy migrate tool from builder stage
|
|
|
|
|
COPY --from=builder /go/bin/migrate /usr/local/bin/
|
2025-09-18 09:23:05 +00:00
|
|
|
COPY --from=builder /app/yanyiwu/ /go/pkg/mod/github.com/yanyiwu/
|
2025-09-18 06:40:07 +00:00
|
|
|
|
2025-08-05 07:08:07 +00:00
|
|
|
# Copy the binary from the builder stage
|
|
|
|
|
COPY --from=builder /app/config ./config
|
|
|
|
|
COPY --from=builder /app/scripts ./scripts
|
|
|
|
|
COPY --from=builder /app/migrations ./migrations
|
|
|
|
|
COPY --from=builder /app/dataset/samples ./dataset/samples
|
2026-02-03 19:40:09 +00:00
|
|
|
COPY --from=builder /app/skills/preloaded ./skills/preloaded
|
2026-03-05 03:53:17 +00:00
|
|
|
# Keep a read-only backup so bind-mount cannot erase built-in skills
|
|
|
|
|
COPY --from=builder /app/skills/preloaded ./skills/_builtin
|
2026-01-05 06:52:11 +00:00
|
|
|
COPY --from=builder /root/.duckdb /home/appuser/.duckdb
|
2025-09-18 06:40:07 +00:00
|
|
|
COPY --from=builder /app/WeKnora .
|
2025-08-05 07:08:07 +00:00
|
|
|
|
2026-03-05 03:53:17 +00:00
|
|
|
# Copy and make entrypoint script executable
|
|
|
|
|
COPY --from=builder /app/scripts/docker-entrypoint.sh ./scripts/docker-entrypoint.sh
|
|
|
|
|
|
2025-08-05 07:08:07 +00:00
|
|
|
# Make scripts executable
|
|
|
|
|
RUN chmod +x ./scripts/*.sh
|
|
|
|
|
|
|
|
|
|
# Expose ports
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
2025-09-11 15:08:13 +00:00
|
|
|
|
2026-03-05 03:53:17 +00:00
|
|
|
ENTRYPOINT ["./scripts/docker-entrypoint.sh"]
|
2025-12-11 17:34:21 +00:00
|
|
|
CMD ["./WeKnora"]
|