-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (52 loc) · 2.06 KB
/
Dockerfile
File metadata and controls
64 lines (52 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM nvidia/cuda:12.6.0-runtime-ubuntu22.04
# Install Python 3.12 + system deps (including XAI/MediaPipe/SAM requirements)
RUN apt-get update && \
apt-get install -y \
python3-pip python3-dev python-is-python3 \
ffmpeg libsm6 libxext6 libgl1-mesa-glx \
libglib2.0-0 \
cmake build-essential \
curl git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --upgrade pip && \
# Install PyTorch with CUDA 11.8 wheels first (GPU-enabled)
pip install --no-cache-dir \
torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/cu118 && \
pip install --no-cache-dir -r requirements.txt && \
# Install segment-anything from source (Meta's SAM)
pip install --no-cache-dir \
git+https://github.com/facebookresearch/segment-anything.git
# Create checkpoint and data directories
RUN mkdir -p /app/checkpoints /app/data/tcav_concepts
# --- SAM Checkpoint ---
# Download SAM ViT-H checkpoint (~2.6 GB) unless mounted as a volume.
# Comment this out and use a volume mount if you want to avoid re-downloading
# on every build (recommended for production):
# volumes:
# - ./checkpoints:/app/checkpoints
#
# RUN curl -L \
# https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth \
# -o /app/checkpoints/sam_vit_h_4b8939.pth
#
# NOTE: The download is commented out by default — use the volume mount in
# docker-compose.yml instead. The SAM technique will log a clear error if the
# checkpoint is missing and fall back gracefully.
# Copy backend code and .env
COPY backend/ ./backend
COPY .env /app/.env
# Copy wait script
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh
# Copy sample data (ensure ml_models is inside backend)
COPY data/ /app/data
COPY GenD_PE_L/ /app/GenD_PE_L
EXPOSE 8000
WORKDIR /app/backend
# Run FastAPI (reload for dev)
CMD /wait-for-it.sh postgres:5432 --timeout=5 -- uvicorn main:app --host 0.0.0.0 --port 8000 --reload