Files
DocsGPT/frontend/Dockerfile
T
Alex aecb596e99 build(docker): slim backend image, static frontend image, -docling variant
Backend (arc53/docsgpt): 4.5 GB compressed -> 0.9 GB with both embedding
models and tiktoken baked in.
- torch/transformers gone from the default install (docling extra only).
- Ubuntu 24.04 ships python3.12: no deadsnakes PPA, no software-properties-
  common; every pin is a wheel, so no gcc/g++/rust in the builder.
- COPY --chown and a prefetch that runs as the process user replace the
  trailing chown -R, which duplicated the 600 MB model layer.
- .dockerignore keeps __pycache__, .coverage, local indexes and .env out.
- EXTRAS build arg (INSTALL_DOCLING kept as an alias); the docling variant
  also bakes docling's layout/table/RapidOCR models (DOCLING_ARTIFACTS_PATH)
  and tesseract, and drops only the discovery documents of Google APIs the
  app never builds.
- FLASK_DEBUG env removed (unused); OCI labels added.

Frontend (arc53/docsgpt-fe): 302 MB Vite dev server -> 25 MB static build
behind nginx. VITE_* variables are injected at container start into
/config.js and read through src/env.ts, so the image no longer needs a
rebuild per deployment; docker-compose.yaml keeps hot reload via the dev
target.

Publishing: every release and develop build now pushes a slim tag and a
-docling tag (docling engine + models + tesseract). docker-compose-hub.yaml
takes DOCSGPT_IMAGE_TAG / DOCSGPT_IMAGE_VARIANT; docker-compose-standalone.yaml
runs the stack from pre-built images without a checkout and is attached to
each release. setup.sh selects the -docling variant for OCR instead of
requiring a local build. A new workflow builds the image on PRs that touch
it and runs verify_offline under --network none; lint checks the exported
requirements match uv.lock.
2026-09-05 15:50:21 +01:00

53 lines
1.7 KiB
Docker

# DocsGPT frontend image: a static production build served by nginx.
#
# Vite inlines VITE_* settings at build time, so the old image ran the Vite
# dev server just to read VITE_API_HOST from the container environment. This
# image builds once and injects the container's VITE_* variables at start-up
# instead (docker/40-runtime-env.sh writes them to /config.js, which the app
# reads before its own bundle; see src/env.ts). Same env vars, same port.
#
# Targets:
# (default) nginx serving the built bundle -- what Docker Hub publishes
# dev the Vite dev server with hot reload, for docker-compose.yaml's
# bind-mounted frontend (build: target: dev)
FROM node:22-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --no-audit --no-fund
FROM deps AS dev
COPY . .
# vite.config.ts polls the filesystem when DOCKER is set: native fs events do
# not cross a Windows host into a Linux container.
ENV DOCKER=1
EXPOSE 5173
CMD ["npm", "run", "dev", "--", "--host"]
FROM deps AS build
COPY . .
# Bake nothing deployment-specific; the runtime script supplies it.
ENV VITE_API_HOST=""
RUN npm run build && \
sed -i 's|<head>|<head><script src="/config.js"></script>|' dist/index.html
FROM nginx:1.27-alpine
LABEL org.opencontainers.image.source="https://github.com/arc53/DocsGPT" \
org.opencontainers.image.title="DocsGPT frontend" \
org.opencontainers.image.licenses="MIT"
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY docker/40-runtime-env.sh /docker-entrypoint.d/40-runtime-env.sh
RUN chmod +x /docker-entrypoint.d/40-runtime-env.sh
COPY --from=build /app/dist /usr/share/nginx/html
# Same port the dev server used, so compose files and docs keep working.
EXPOSE 5173