/ .devcontainer / Dockerfile
Dockerfile
 1  ARG PYTHON_VERSION=3.12
 2  FROM mcr.microsoft.com/devcontainers/python:${PYTHON_VERSION}
 3  
 4  # Install UV and Bun
 5  RUN curl -fsSL https://bun.sh/install | bash && mv /root/.bun/bin/bun /usr/local/bin/bun
 6  COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
 7  RUN uv python pin $PYTHON_VERSION
 8  # create python virtual environment
 9  RUN uv venv /opt/venv --python $PYTHON_VERSION --seed
10  # Add venv to PATH for subsequent RUN commands and for the container environment
11  ENV PATH="/opt/venv/bin:$PATH"
12  # Tell pip, uv to use this virtual environment
13  ENV VIRTUAL_ENV="/opt/venv"
14  ENV UV_PROJECT_ENVIRONMENT="/opt/venv"
15  
16  # Setup working directory
17  WORKDIR /workspaces/khoj
18  
19  # --- Python Server App Dependencies ---
20  # Copy files required for Python dependency installation.
21  COPY pyproject.toml README.md ./
22  
23  # Setup python environment
24      # Use the pre-built torch cpu wheel
25  ENV UV_INDEX="https://download.pytorch.org/whl/cpu" \
26      UV_INDEX_STRATEGY="unsafe-best-match" \
27      # Avoid downloading unused cuda specific python packages
28      CUDA_VISIBLE_DEVICES="" \
29      # Use static version to build app without git dependency
30      VERSION=0.0.0 \
31      # Use embedded db
32      USE_EMBEDDED_DB="True" \
33      PGSERVER_DATA_DIR="/opt/khoj_db"
34  # Install Python dependencies from pyproject.toml in editable mode
35  RUN sed -i "s/dynamic = \\[\"version\"\\]/version = \"$VERSION\"/" pyproject.toml && \
36      uv sync --all-extras && \
37      # Save the lock file generated with correct Linux platform wheels
38      cp uv.lock /opt/uv.lock.linux && \
39      chown -R vscode:vscode /opt/venv
40  
41  # --- Web App Dependencies ---
42  # Copy web app manifest files
43  COPY src/interface/web/package.json src/interface/web/bun.lock /opt/khoj_web/
44  
45  # Install web app dependencies
46  RUN cd /opt/khoj_web && bun install && chown -R vscode:vscode .
47  
48  # The .venv and node_modules are now populated in the image.
49  # The rest of the source code will be mounted by VS Code from your local checkout,
50  # overlaying any files copied here if they are part of the workspace mount.