Skip to content

Commit 8451aa5

Browse files
authored
Update Dockerfile
1 parent 4381dfc commit 8451aa5

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Dockerfile

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
1-
# 1. PLATFORM PINNING: Essential for CUDA wheels.
2-
# PyTorch with CUDA does not have wheels for ARM64 (Apple Silicon).
3-
# We force linux/amd64 so Docker pulls the compatible x86 binary.
1+
# 1. PLATFORM PINNING
42
FROM --platform=linux/amd64 python:3.11-slim
53

64
# 2. ENVIRONMENT VARIABLES
7-
# Keeps Python from buffering stdout/stderr (logs appear immediately)
8-
# and prevents python from writing .pyc files.
95
ENV PYTHONDONTWRITEBYTECODE=1 \
106
PYTHONUNBUFFERED=1 \
11-
PIP_NO_CACHE_DIR=1
7+
PIP_NO_CACHE_DIR=1 \
8+
TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0"
129

1310
WORKDIR /app
1411

1512
# 3. SYSTEM DEPENDENCIES
16-
# Install basic build tools and libraries often required by vision/audio packages
1713
RUN apt-get update && apt-get install -y --no-install-recommends \
1814
build-essential \
1915
git \
2016
libgl1 \
2117
libglib2.0-0 \
18+
# wget/curl often useful in notebooks
19+
wget \
20+
curl \
2221
&& rm -rf /var/lib/apt/lists/*
2322

2423
# 4. INSTALL PYTORCH (Heavy Layer)
25-
# We do this BEFORE copying requirements.txt or app code.
26-
# This ensures Docker caches this heavy layer (2GB+) and doesn't re-download
27-
# it unless you specifically change the Torch version.
2824
RUN pip install --upgrade pip setuptools wheel && \
2925
pip install \
3026
torch==2.7.0 \
3127
torchvision==0.22.0 \
3228
torchaudio==2.7.0 \
3329
--index-url https://download.pytorch.org/whl/cu126
3430

35-
# 5. INSTALL OTHER REQUIREMENTS
36-
COPY requirements.txt .
37-
RUN pip install -r requirements.txt
31+
# 5. CLONE SAM 3 & INSTALL JUPYTER
32+
# We install sam3 AND jupyterlab here
33+
RUN git clone https://github.com/facebookresearch/sam3.git && \
34+
cd sam3 && \
35+
pip install -e . && \
36+
pip install jupyterlab matplotlib ipywidgets
3837

39-
# 6. SECURITY: CREATE NON-ROOT USER
40-
# Running as root is a security risk. Create a user 'appuser'.
38+
# 6. SECURITY: NON-ROOT USER
4139
RUN addgroup --system --gid 1001 appgroup && \
4240
adduser --system --uid 1001 --gid 1001 appuser
4341

44-
# 7. COPY APP CODE
45-
COPY . .
46-
47-
# Change ownership of the app directory to the non-root user
42+
# Grant ownership so Jupyter can write notebooks to /app
4843
RUN chown -R appuser:appgroup /app
4944

5045
# Switch to non-root user
5146
USER appuser
5247

48+
# 7. CONFIGURATION
49+
# Expose the standard Jupyter port
50+
EXPOSE 8888
51+
5352
# 8. ENTRYPOINT
54-
# Update 'main.py' to your actual entry script
55-
CMD ["python", "main.py"]
53+
# --ip=0.0.0.0: Allows connections from outside the container
54+
# --no-browser: Prevents it from trying to open a browser inside the container
55+
# --NotebookApp.token='': (Optional) Disables password for easier local dev
56+
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--NotebookApp.token=''"]

0 commit comments

Comments
 (0)