UnisKB/installer/Dockerfile

75 lines
2.7 KiB
Docker
Raw Normal View History

2024-08-15 08:20:12 +00:00
FROM ghcr.io/1panel-dev/maxkb-vector-model:v1.0.1 AS vector-model
FROM node:18-alpine3.18 AS web-build
2024-03-25 07:35:28 +00:00
COPY ui ui
RUN cd ui && \
npm install && \
npm run build && \
rm -rf ./node_modules
FROM ghcr.io/1panel-dev/maxkb-python-pg:python3.11-pg15.8 AS stage-build
2024-01-31 08:55:35 +00:00
2024-03-25 04:28:55 +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
RUN mkdir -p /opt/maxkb/app /opt/maxkb/model /opt/maxkb/conf && \
2024-08-15 11:13:04 +00:00
rm -rf /opt/maxkb/app/ui
2024-08-15 09:17:25 +00:00
2024-03-25 07:35:28 +00:00
COPY --from=web-build ui /opt/maxkb/app/ui
2024-03-25 04:28:55 +00:00
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 && \
2024-03-26 09:24:20 +00:00
if [ "$(uname -m)" = "x86_64" ]; then sed -i 's/^torch.*/torch = {version = "^2.2.1+cpu", source = "pytorch"}/g' pyproject.toml; fi && \
2024-03-25 04:28:55 +00:00
poetry install
FROM ghcr.io/1panel-dev/maxkb-python-pg:python3.11-pg15.8
2024-03-25 04:28:55 +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=root \
MAXKB_DB_PASSWORD=Password123@postgres \
MAXKB_EMBEDDING_MODEL_NAME=/opt/maxkb/model/embedding/shibing624_text2vec-base-chinese \
2024-08-14 06:37:40 +00:00
MAXKB_EMBEDDING_MODEL_PATH=/opt/maxkb/model/embedding \
2024-12-06 03:14:48 +00:00
MAXKB_SANDBOX=1 \
2024-08-14 06:37:40 +00:00
LANG=en_US.UTF-8 \
PATH=/opt/py3/bin:$PATH \
2024-08-14 11:34:54 +00:00
POSTGRES_USER=root \
POSTGRES_PASSWORD=Password123@postgres \
PIP_TARGET=/opt/maxkb/app/sandbox/python-packages \
PYTHONPATH=/opt/maxkb/app/sandbox/python-packages \
2024-08-21 10:37:47 +00:00
PYTHONUNBUFFERED=1
2024-03-25 07:07:14 +00:00
WORKDIR /opt/maxkb/app
COPY --from=stage-build /opt/maxkb /opt/maxkb
2024-03-25 04:28:55 +00:00
COPY --from=stage-build /opt/py3 /opt/py3
2024-04-11 10:18:42 +00:00
COPY --from=vector-model /opt/maxkb/app/model /opt/maxkb/model
2024-03-25 04:28:55 +00:00
2024-04-11 10:18:42 +00:00
RUN chmod 755 /opt/maxkb/app/installer/run-maxkb.sh && \
2024-03-19 10:52:42 +00:00
cp -r /opt/maxkb/model/base/hub /opt/maxkb/model/tokenizer && \
2024-03-25 04:28:55 +00:00
cp -f /opt/maxkb/app/installer/run-maxkb.sh /usr/bin/run-maxkb.sh && \
2024-08-15 11:13:04 +00:00
cp -f /opt/maxkb/app/installer/init.sql /docker-entrypoint-initdb.d && \
mkdir -p /opt/maxkb/app/sandbox/python-packages && \
find /opt/maxkb/app -mindepth 1 -not -name 'sandbox' -exec chmod 700 {} + && \
chmod 755 /tmp && \
2024-08-15 11:13:04 +00:00
useradd --no-create-home --home /opt/maxkb/app/sandbox --shell /bin/bash sandbox && \
chown sandbox:sandbox /opt/maxkb/app/sandbox && \
2024-12-17 02:40:43 +00:00
curl -L --connect-timeout 120 -m 1800 https://resource-fit2cloud-com.oss-cn-hangzhou.aliyuncs.com/maxkb/ffmpeg/get-ffmpeg-linux | sh
2024-08-15 11:13:04 +00:00
2024-03-25 04:28:55 +00:00
2024-03-19 11:59:54 +00:00
EXPOSE 8080
2024-03-25 04:28:55 +00:00
2024-03-15 02:54:29 +00:00
ENTRYPOINT ["bash", "-c"]
2024-08-16 09:39:41 +00:00
CMD [ "/usr/bin/run-maxkb.sh" ]