diff --git a/installer/Dockerfile-dev b/installer/Dockerfile-dev new file mode 100644 index 000000000..3e696d9f7 --- /dev/null +++ b/installer/Dockerfile-dev @@ -0,0 +1,80 @@ +FROM debian:bookworm-slim as stage-base +ARG DEPENDENCIES=" \ + python3-pip \ + python3.11-mini \ + python3.11-venv" + +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 +RUN mkdir -p /opt/maxkb/app /opt/maxkb/model /opt/maxkb/conf && \ + cp -f /opt/maxkb/app/installer/config.yaml /opt/maxkb/conf && \ + rm -rf /opt/maxkb/app/ui + +FROM python:3.11-slim-bookworm as vector-model +COPY installer/install_model.py install_model.py +RUN --mount=type=cache,target=/root/.cache \ + pip3 install --upgrade pip setuptools && \ + pip install pycrawlers && \ + pip install transformers && \ + python3 install_model.py + +FROM node:18-bookworm-slim as web-build +COPY ui ui +RUN cd ui && \ + npm install && \ + npm run build && \ + rm -rf ./node_modules + +FROM stage-base as stage-build +WORKDIR /opt/maxkb/app +RUN python3 -m venv /opt/py3 && \ + pip install poetry --break-system-packages && \ + poetry config virtualenvs.create false && \ + . /opt/py3/bin/activate && \ + if [ "$(uname -m)" != "x86_64" ]; then sed -i '/^torch/d' pyproject.toml; fi && \ + poetry install + +FROM postgres:15.6-bookworm +ARG DOCKER_IMAGE_TAG=dev \ + BUILD_AT \ + GITHUB_COMMIT + +ENV MAXKB_VERSION ${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_COMMIT}) + +ARG DEPENDENCIES=" \ + curl \ + python3.11-mini \ + python3.11-venv \ + postgresql-15-pgvector" + +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo "Asia/Shanghai" > /etc/timezone && \ + apt-get update && apt-get install -y --no-install-recommends $DEPENDENCIES && \ + apt-get clean all && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=stage-build /opt/py3 /opt/py3 +COPY --from=stage-build /opt/maxkb /opt/maxkb +COPY --from=vector-model model /opt/maxkb/app/model +COPY --from=web-build ui /opt/maxkb/app/ui + +ENV LANG=en_US.UTF-8 \ + PATH=/opt/py3/bin:$PATH + +ENV POSTGRES_USER root +ENV POSTGRES_PASSWORD Password123@postgres + +RUN mv /opt/maxkb/app/model/* /opt/maxkb/model && \ + chmod 755 /opt/maxkb/app/installer/run-maxkb.sh && \ + cp -r /opt/maxkb/model/base/hub /opt/maxkb/model/tokenizer && \ + cp -f /opt/maxkb/app/installer/init.sql /docker-entrypoint-initdb.d && \ + cp -f /opt/maxkb/app/installer/run-maxkb.sh /usr/bin/run-maxkb.sh + +EXPOSE 8080 + +ENTRYPOINT ["bash", "-c"] +CMD [ "/usr/bin/run-maxkb.sh" ] \ No newline at end of file