Add modular system package installation support

Implemented SYSTEM_PACKAGES environment variable for flexible system library installation:

Key Features:
- Users specify packages in .env: SYSTEM_PACKAGES="libopenslide0 libgdal-dev"
- Packages installed during Docker build (secure, no runtime mounting)
- Automatic rebuild detection when packages change
- Documentation with common scientific computing packages

Technical Implementation:
- ARG SYSTEM_PACKAGES in Dockerfile with conditional apt-get install
- Build argument passed from claude-docker.sh script
- Clean package management with cache cleanup

Benefits:
- Secure: No system directory mounting required
- Flexible: Users choose exactly what they need
- Documented: Common packages listed in README
- Clean: Packages baked into image, not mounted at runtime

Tested successfully with OpenSlide: conda run -n prism python -c "import openslide"
This commit is contained in:
Vishal Jain 2025-06-18 01:21:25 +01:00
parent 70040a7444
commit 066233b03c
3 changed files with 71 additions and 2 deletions

View File

@ -13,6 +13,16 @@ TWILIO_TO_NUMBER=+0987654321
# Optional: Custom conda installation (for academic/lab environments) # Optional: Custom conda installation (for academic/lab environments)
# Example: CONDA_PREFIX=/vol/biomedic3/username/miniconda3 # Example: CONDA_PREFIX=/vol/biomedic3/username/miniconda3
CONDA_PREFIX= CONDA_PREFIX=
# Optional: Additional conda directories (space-separated list) # Optional: Additional conda directories (space-separated list)
# Directories are mounted to the same path inside the container
# Automatic detection:
# - Paths with "*env*" are added to CONDA_ENVS_DIRS (for environments)
# - Paths with "*pkg*" are added to CONDA_PKGS_DIRS (for package cache)
# Example: CONDA_EXTRA_DIRS="/vol/biomedic3/username/.conda/envs /vol/biomedic3/username/conda_envs /vol/biomedic3/username/.conda/pkgs /vol/biomedic3/username/conda_pkgs /homes/username/.conda/envs" # Example: CONDA_EXTRA_DIRS="/vol/biomedic3/username/.conda/envs /vol/biomedic3/username/conda_envs /vol/biomedic3/username/.conda/pkgs /vol/biomedic3/username/conda_pkgs /homes/username/.conda/envs"
CONDA_EXTRA_DIRS= CONDA_EXTRA_DIRS=
# Optional: System packages to install in Docker container (space-separated)
# Common scientific packages: libopenslide0 libgdal-dev libproj-dev libopencv-dev
# Example: SYSTEM_PACKAGES="libopenslide0 libgdal-dev"
SYSTEM_PACKAGES=

View File

@ -12,6 +12,17 @@ RUN apt-get update && apt-get install -y \
sudo \ sudo \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Install additional system packages if specified
ARG SYSTEM_PACKAGES=""
RUN if [ -n "$SYSTEM_PACKAGES" ]; then \
echo "Installing additional system packages: $SYSTEM_PACKAGES" && \
apt-get update && \
apt-get install -y $SYSTEM_PACKAGES && \
rm -rf /var/lib/apt/lists/*; \
else \
echo "No additional system packages specified"; \
fi
# Create a non-root user with matching host UID/GID # Create a non-root user with matching host UID/GID
ARG USER_UID=1000 ARG USER_UID=1000
ARG USER_GID=1000 ARG USER_GID=1000

View File

@ -113,6 +113,12 @@ This workflow gives you:
- Configurable via MCP integration - Configurable via MCP integration
- Optional - works without if Twilio not configured - Optional - works without if Twilio not configured
### 🐍 Conda Integration
- Supports custom conda installations (ideal for academic/lab environments)
- Mounts conda directories to preserve original paths and configurations
- Automatic environment variable configuration for seamless conda usage
- Works with environments and package caches in non-standard locations
### 🗂️ Context Persistence ### 🗂️ Context Persistence
- Maintains scratchpad.md files for project memory - Maintains scratchpad.md files for project memory
- Persistent across container sessions - Persistent across container sessions
@ -181,7 +187,49 @@ claude-docker
Rebuild when you: Rebuild when you:
- Update your .env file with new credentials - Update your .env file with new credentials
- Update the Claude Docker repository - Update the Claude Docker repository
- Want to refresh the authentication files
### Conda Configuration
For custom conda installations (common in academic/lab environments), add these to your `.env` file:
```bash
# Main conda installation
CONDA_PREFIX=/vol/biomedic3/username/miniconda3
# Additional conda directories (space-separated)
CONDA_EXTRA_DIRS="/vol/biomedic3/username/.conda/envs /vol/biomedic3/username/conda_envs /vol/biomedic3/username/.conda/pkgs /vol/biomedic3/username/conda_pkgs"
```
**How it works:**
- `CONDA_PREFIX`: Mounts your conda installation to the same path in container
- `CONDA_EXTRA_DIRS`: Mounts additional directories and automatically configures conda
**Automatic Detection:**
- Paths containing `*env*` → Added to `CONDA_ENVS_DIRS` (conda environment search)
- Paths containing `*pkg*` → Added to `CONDA_PKGS_DIRS` (package cache search)
**Result:** All your conda environments and packages work exactly as they do on your host system.
### System Package Installation
For scientific computing packages that require system libraries, add them to your `.env` file:
```bash
# Install OpenSlide for medical imaging
SYSTEM_PACKAGES="libopenslide0"
# Install multiple packages (space-separated)
SYSTEM_PACKAGES="libopenslide0 libgdal-dev libproj-dev libopencv-dev"
```
**Common packages:**
- `libopenslide0` - OpenSlide for whole slide imaging
- `libgdal-dev` - GDAL for geospatial data
- `libproj-dev` - PROJ for cartographic projections
- `libopencv-dev` - OpenCV for computer vision
- `libfftw3-dev` - FFTW for fast Fourier transforms
**Note:** Adding system packages requires rebuilding the Docker image (`docker rmi claude-docker:latest`).
## Requirements ## Requirements