Skip to content

Commit b999eb7

Browse files
committed
fix: make SAM3 Docker dependencies opt-in
1 parent df999d5 commit b999eb7

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎backend/.dockerignore‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Python
22
.venv/
3+
.venv-sam3/
34
sam3-venv/
45
__pycache__/
56
*.pyc
@@ -32,4 +33,13 @@ Thumbs.db
3233
# Data
3334
uploads/
3435
training_runs/
36+
trained_models/
3537
model/
38+
pretrained/
39+
external_models/
40+
import_chunks/
41+
import_progress/
42+
*.db
43+
*.sqlite
44+
*.sqlite3
45+
*.log

‎backend/Dockerfile‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,54 @@
1-
# Build stage
1+
# Build stage — SAM3 support is opt-in to keep default image size small
22
FROM python:3.12-slim as builder
33

44
WORKDIR /app
55

6-
# Install build dependencies
6+
ARG INSTALL_SAM3=false
7+
78
RUN apt-get update && apt-get install -y --no-install-recommends \
89
libpq-dev gcc \
910
&& rm -rf /var/lib/apt/lists/*
1011

11-
# Install Python dependencies
1212
COPY requirements.txt requirements-sam3.txt ./
1313
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt \
14-
&& python -m venv /sam3-venv \
15-
&& /sam3-venv/bin/pip install --no-cache-dir -r requirements-sam3.txt
14+
&& mkdir -p /sam3-venv \
15+
&& if [ "$INSTALL_SAM3" = "true" ]; then \
16+
python -m venv /sam3-venv \
17+
&& /sam3-venv/bin/pip install --no-cache-dir -r requirements-sam3.txt; \
18+
fi
1619

1720
# Production stage
1821
FROM python:3.12-slim
1922

2023
WORKDIR /app
2124

22-
# Install runtime dependencies only
25+
ARG INSTALL_SAM3=false
26+
2327
RUN apt-get update && apt-get install -y --no-install-recommends \
2428
libpq5 ffmpeg \
2529
&& rm -rf /var/lib/apt/lists/*
2630

27-
# Copy decord stub (decord is Linux-only, not needed by LocateAnything-3B)
2831
COPY decord_stub.py /usr/local/lib/python3.12/site-packages/decord.py
2932

30-
# Copy Python packages from builder
3133
COPY --from=builder /install /usr/local
32-
# Copy SAM3 venv
3334
COPY --from=builder /sam3-venv /app/sam3-venv
3435

35-
# Create non-root user and data directories
3636
RUN useradd -m -u 1000 appuser \
3737
&& mkdir -p /app/uploads /app/model /app/training_runs \
3838
&& chown -R appuser:appuser /app
3939
USER appuser
4040

41-
# Copy application code
4241
COPY --chown=appuser:appuser app ./app
4342
COPY --chown=appuser:appuser sam3_server.py .
4443
COPY --chown=appuser:appuser alembic.ini .
4544
COPY --chown=appuser:appuser alembic ./alembic
4645

47-
# Set environment variables
4846
ENV PYTHONPATH=/app \
4947
PYTHONUNBUFFERED=1 \
5048
PYTHONDONTWRITEBYTECODE=1
5149

5250
EXPOSE 8000 8002
5351

54-
# Health check
5552
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
5653
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"
5754

0 commit comments

Comments
 (0)