2022-01-23 19:57:28 +00:00
|
|
|
# syntax=docker/dockerfile:1
|
2024-11-24 05:13:51 +00:00
|
|
|
FROM ubuntu:jammy AS base
|
2024-07-19 11:40:08 +00:00
|
|
|
LABEL homepage="https://khoj.dev"
|
|
|
|
LABEL repository="https://github.com/khoj-ai/khoj"
|
|
|
|
LABEL org.opencontainers.image.source="https://github.com/khoj-ai/khoj"
|
2024-09-29 10:52:11 +00:00
|
|
|
LABEL org.opencontainers.image.description="Your second brain, containerized for personal, local deployment."
|
2022-01-23 19:57:28 +00:00
|
|
|
|
2022-08-03 20:00:20 +00:00
|
|
|
# Install System Dependencies
|
2024-09-29 10:52:11 +00:00
|
|
|
RUN apt update -y && apt -y install \
|
|
|
|
python3-pip \
|
|
|
|
swig \
|
|
|
|
curl \
|
|
|
|
# Required by RapidOCR
|
|
|
|
libgl1 \
|
|
|
|
libglx-mesa0 \
|
2024-11-24 05:13:51 +00:00
|
|
|
libglib2.0-0 \
|
2024-11-24 02:46:44 +00:00
|
|
|
# Required by llama-cpp-python pre-built wheels. See #1628
|
2024-11-24 05:13:51 +00:00
|
|
|
musl-dev && \
|
|
|
|
ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 && \
|
|
|
|
# Clean up
|
|
|
|
apt clean && rm -rf /var/lib/apt/lists/*
|
2024-07-08 12:50:46 +00:00
|
|
|
|
2024-11-24 05:13:51 +00:00
|
|
|
# Build Server
|
|
|
|
FROM base AS server-deps
|
2024-06-22 14:42:41 +00:00
|
|
|
WORKDIR /app
|
2023-10-26 16:42:29 +00:00
|
|
|
COPY pyproject.toml .
|
|
|
|
COPY README.md .
|
2023-12-21 11:37:08 +00:00
|
|
|
ARG VERSION=0.0.0
|
2024-11-24 06:24:45 +00:00
|
|
|
# use the pre-built llama-cpp-python, torch cpu wheel
|
|
|
|
ENV PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu https://abetlen.github.io/llama-cpp-python/whl/cpu"
|
|
|
|
# avoid downloading unused cuda specific python packages
|
|
|
|
ENV CUDA_VISIBLE_DEVICES=""
|
2023-12-21 11:37:08 +00:00
|
|
|
RUN sed -i "s/dynamic = \\[\"version\"\\]/version = \"$VERSION\"/" pyproject.toml && \
|
2023-07-11 07:41:05 +00:00
|
|
|
pip install --no-cache-dir .
|
2022-01-23 19:57:28 +00:00
|
|
|
|
2024-11-24 05:13:51 +00:00
|
|
|
# Build Web App
|
|
|
|
FROM node:20-alpine AS web-app
|
2024-11-24 20:59:17 +00:00
|
|
|
# Set build optimization env vars
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2024-11-24 05:13:51 +00:00
|
|
|
COPY src/interface/web /app/src/interface/web
|
2024-06-22 14:42:41 +00:00
|
|
|
WORKDIR /app/src/interface/web
|
2024-11-24 05:13:51 +00:00
|
|
|
RUN yarn install --frozen-lockfile && \
|
|
|
|
yarn build
|
|
|
|
|
|
|
|
# Merge the Server and Web App into a Single Image
|
|
|
|
FROM base
|
|
|
|
ENV PYTHONPATH=/app/src
|
2024-06-22 14:42:41 +00:00
|
|
|
WORKDIR /app
|
2024-11-24 05:13:51 +00:00
|
|
|
COPY --from=server-deps /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
|
|
|
|
COPY --from=web-app /app/src/interface/web/out ./src/khoj/interface/built
|
|
|
|
COPY . .
|
|
|
|
RUN cd src && python3 khoj/manage.py collectstatic --noinput
|
2024-06-22 14:42:41 +00:00
|
|
|
|
2022-08-03 20:00:20 +00:00
|
|
|
# Run the Application
|
|
|
|
# There are more arguments required for the application to run,
|
2024-11-24 05:13:51 +00:00
|
|
|
# but those should be passed in through the docker-compose.yml file.
|
2022-08-03 20:00:20 +00:00
|
|
|
ARG PORT
|
|
|
|
EXPOSE ${PORT}
|
2023-10-26 16:42:29 +00:00
|
|
|
ENTRYPOINT ["python3", "src/khoj/main.py"]
|