UnisKB/installer/Dockerfile

73 lines
2.7 KiB
Docker
Raw Normal View History

2025-04-18 06:10:16 +00:00
FROM node:18-alpine3.18 AS web-build
COPY ui ui
RUN cd ui && \
npm install && \
NODE_OPTIONS="--max-old-space-size=4096" npm run build-only && \
NODE_OPTIONS="--max-old-space-size=4096" npm run build-only-chat && \
2025-06-24 07:50:25 +00:00
find . -maxdepth 1 ! -name '.' ! -name 'dist' ! -name 'public' -exec rm -rf {} +
2025-07-09 01:59:59 +00:00
2025-07-08 07:22:09 +00:00
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.5 AS stage-build
2025-04-18 06:10:16 +00:00
ARG DEPENDENCIES=" \
python3-pip"
RUN apt-get update && \
apt-get install -y --no-install-recommends $DEPENDENCIES && \
apt-get clean all && \
rm -rf /var/lib/apt/lists/*
COPY . /opt/maxkb-app
2025-06-25 02:29:49 +00:00
2025-04-18 06:10:16 +00:00
WORKDIR /opt/maxkb-app
2025-07-09 01:59:59 +00:00
RUN rm -rf /opt/maxkb-app/ui && \
python3 -m venv /opt/py3 && \
pip install poetry==2.0.0 --break-system-packages && \
2025-04-18 06:10:16 +00:00
poetry config virtualenvs.create false && \
. /opt/py3/bin/activate && \
2025-06-16 03:36:39 +00:00
if [ "$(uname -m)" = "x86_64" ]; then sed -i 's/^torch.*/torch = {version = "2.7.1+cpu", source = "pytorch"}/g' pyproject.toml; fi && \
2025-04-18 06:10:16 +00:00
poetry install && \
2025-06-24 08:13:59 +00:00
find /opt/maxkb-app -depth \( -name ".git*" -o -name ".docker*" -o -name ".idea*" -o -name ".editorconfig*" -o -name ".prettierrc*" -o -name "README.md" -o -name "poetry.lock" -o -name "pyproject.toml" \) -exec rm -rf {} + && \
export MAXKB_CONFIG_TYPE=ENV && python3 /opt/maxkb-app/apps/manage.py compilemessages && \
export PIP_TARGET=/opt/maxkb-app/sandbox/python-packages && \
2025-06-24 10:23:30 +00:00
pip install diskcache2 requests pymysql psycopg2-binary && \
rm -rf /opt/maxkb-app/installer
2025-04-18 06:10:16 +00:00
2025-07-08 07:22:09 +00:00
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.5
2025-04-18 06:10:16 +00:00
ARG DOCKER_IMAGE_TAG=dev \
BUILD_AT \
GITHUB_COMMIT
ENV MAXKB_VERSION="${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_COMMIT})" \
MAXKB_CONFIG_TYPE=ENV \
MAXKB_DB_NAME=maxkb \
MAXKB_DB_HOST=127.0.0.1 \
MAXKB_DB_PORT=5432 \
MAXKB_DB_USER=${POSTGRES_USER} \
MAXKB_DB_PASSWORD=${POSTGRES_PASSWORD} \
MAXKB_DB_MAX_OVERFLOW=80 \
2025-04-18 06:17:59 +00:00
MAXKB_REDIS_HOST=127.0.0.1 \
2025-06-04 05:59:59 +00:00
MAXKB_REDIS_PORT=6379 \
2025-06-16 08:44:58 +00:00
MAXKB_REDIS_DB=0 \
2025-04-18 06:17:59 +00:00
MAXKB_REDIS_PASSWORD=${REDIS_PASSWORD} \
2025-04-18 06:10:16 +00:00
MAXKB_EMBEDDING_MODEL_PATH=/opt/maxkb-app/model/embedding \
2025-04-18 06:45:36 +00:00
MAXKB_EMBEDDING_MODEL_NAME=/opt/maxkb-app/model/embedding/shibing624_text2vec-base-chinese \
MAXKB_LOCAL_MODEL_HOST=127.0.0.1 \
MAXKB_LOCAL_MODEL_PORT=11636 \
MAXKB_LOCAL_MODEL_PROTOCOL=http \
2025-04-18 06:10:16 +00:00
MAXKB_SANDBOX=1 \
PATH=/opt/py3/bin:$PATH \
PIP_TARGET=/opt/maxkb/python-packages \
PYTHONUNBUFFERED=1
2025-04-21 08:39:20 +00:00
WORKDIR /opt/maxkb-app
2025-04-18 06:17:59 +00:00
COPY --from=stage-build /opt/maxkb-app /opt/maxkb-app
2025-07-09 01:59:59 +00:00
COPY --from=web-build ui /opt/maxkb-app/ui
2025-04-18 06:10:16 +00:00
COPY --from=stage-build /opt/py3 /opt/py3
2025-06-24 09:38:02 +00:00
RUN chmod 755 /tmp && \
2025-07-09 01:59:59 +00:00
find /opt/maxkb-app -mindepth 1 -not -name 'sandbox' -exec chmod 700 {} +
2025-04-18 06:10:16 +00:00
EXPOSE 8080
VOLUME /opt/maxkb
ENTRYPOINT ["bash", "-c"]
CMD [ "/usr/bin/start-all.sh" ]