44 lines
2.6 KiB
Docker
44 lines
2.6 KiB
Docker
FROM node:24-alpine AS web-build
|
|
WORKDIR /build/ui
|
|
COPY ui/package.json ui/pnpm-lock.yaml ui/pnpm-workspace.yaml ./
|
|
RUN npm install -g pnpm@11.23.0 && pnpm install --frozen-lockfile --shamefully-hoist
|
|
COPY ui/ ./
|
|
# Never reuse dist or Vite's relative development base for a release.
|
|
RUN rm -rf dist && npm run build-only -- --base /admin/ && npm run build-only-chat -- --base /chat/ && \
|
|
test -f dist/admin/index.html && test -f dist/chat/index.html && \
|
|
grep -q '/admin/assets/' dist/admin/index.html
|
|
|
|
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6 AS backend-build
|
|
ARG UV_INDEX_URL
|
|
ENV UV_HTTP_TIMEOUT=30 UV_HTTP_RETRIES=2
|
|
WORKDIR /opt/maxkb-app
|
|
COPY . .
|
|
RUN printf 'deb https://mirrors.aliyun.com/debian trixie main\n' > /tmp/unis-build.list && \
|
|
timeout 180s apt-get -o Dir::Etc::sourcelist=/tmp/unis-build.list -o Dir::Etc::sourceparts=- -o Acquire::ForceIPv4=true -o Acquire::https::Timeout=30 -o Acquire::Retries=1 update && \
|
|
timeout 180s apt-get -o Dir::Etc::sourcelist=/tmp/unis-build.list -o Dir::Etc::sourceparts=- -o Acquire::ForceIPv4=true -o Acquire::https::Timeout=30 -o Acquire::Retries=1 install -y --no-install-recommends gcc g++ gettext libexpat1-dev libffi-dev
|
|
RUN gcc -shared -fPIC -o ${MAXKB_SANDBOX_HOME}/sandbox.so installer/sandbox.c -ldl && \
|
|
pip install uv --break-system-packages && printf 'pydantic==2.12.3\n' > /tmp/unis-kb-constraints.txt && \
|
|
timeout 600s python -m uv pip install -c /tmp/unis-kb-constraints.txt -r pyproject.toml && \
|
|
python -c 'from pydantic._internal._typing_extra import eval_type_backport; import mcp.types' && python -m pip check && \
|
|
python apps/manage.py compilemessages && \
|
|
python -m uv pip install --target=/opt/maxkb-app/sandbox/python-packages requests pymysql psycopg2-binary && \
|
|
rm -rf ui installer deploy_artifacts && rm -rf /var/lib/apt/lists/*
|
|
|
|
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6
|
|
ARG RELEASE_VERSION
|
|
ARG GITHUB_COMMIT
|
|
LABEL io.unis.component=kb io.unis.layout=refact org.opencontainers.image.revision=${GITHUB_COMMIT}
|
|
ENV MAXKB_VERSION="${RELEASE_VERSION} (${GITHUB_COMMIT})" \
|
|
AI_HUB_ASSET_DIR=/opt/maxkb/data/ai-hub-assets
|
|
WORKDIR /opt/maxkb-app
|
|
COPY --from=backend-build /opt/maxkb-app /opt/maxkb-app
|
|
COPY --from=backend-build /opt/py3 /opt/py3
|
|
# main.py collect_static also uses ui/dist. Ship both locations in the image.
|
|
COPY --from=web-build /build/ui/dist /opt/maxkb-app/ui/dist
|
|
COPY --from=web-build /build/ui/dist /opt/maxkb-app/apps/static
|
|
COPY deploy_artifacts/check_internal_services.py /usr/local/bin/unis-check-internal-services.py
|
|
EXPOSE 8080
|
|
VOLUME /opt/maxkb
|
|
ENTRYPOINT ["bash", "-c"]
|
|
CMD ["/usr/bin/start-all.sh"]
|