|
1 | | -# BioAnalyzer Backend Dockerfile |
2 | 1 | FROM python:3.11-slim |
3 | 2 |
|
4 | 3 | WORKDIR /app |
5 | | - |
6 | | -# FIX: Make Python recognize the application as a package |
7 | 4 | ENV PYTHONPATH="/app:/app/app" |
8 | 5 |
|
9 | | -# Install system dependencies |
10 | 6 | RUN apt-get update && apt-get install -y \ |
11 | | - gcc \ |
12 | | - g++ \ |
13 | | - curl \ |
14 | | - git \ |
| 7 | + gcc g++ curl git \ |
15 | 8 | && rm -rf /var/lib/apt/lists/* |
16 | 9 |
|
17 | | -# Copy pyproject.toml and README.md first for better caching |
18 | 10 | COPY pyproject.toml README.md ./ |
19 | 11 |
|
20 | | -# Upgrade pip and setuptools first |
21 | 12 | RUN pip install --upgrade pip setuptools wheel build |
22 | 13 |
|
23 | | -# ------------------------------------------------------------ |
24 | | -# Step 1: Install PyTorch CPU versions (fixed +cpu issue) |
25 | | -# Note: PyTorch CPU versions require special index URL, so we install them separately |
26 | | -# before installing the package from pyproject.toml |
27 | | -# ------------------------------------------------------------ |
28 | | -RUN pip install --no-cache-dir --default-timeout=600 --retries=10 \ |
29 | | - --extra-index-url https://download.pytorch.org/whl/cpu \ |
30 | | - torch==2.1.0+cpu \ |
31 | | - torchvision==0.16.0+cpu \ |
32 | | - torchaudio==2.1.0+cpu |
| 14 | +# Install PyTorch CPU wheels |
| 15 | +RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu \ |
| 16 | + torch==2.1.0+cpu torchvision==0.16.0+cpu torchaudio==2.1.0+cpu |
33 | 17 |
|
34 | | -# ------------------------------------------------------------ |
35 | | -# Step 2: Copy application code |
36 | | -# ------------------------------------------------------------ |
37 | 18 | COPY . . |
38 | 19 |
|
39 | | -# ------------------------------------------------------------ |
40 | | -# Step 3: Install the package from pyproject.toml |
41 | | -# This installs the package and all its dependencies from pyproject.toml |
42 | | -# PyTorch is already installed above, so pip will skip it |
43 | | -# Installing in editable mode (-e) ensures entry points are properly installed |
44 | | -# ------------------------------------------------------------ |
45 | | -RUN pip install --no-cache-dir --default-timeout=300 --retries=5 -e . |
| 20 | +# Install package + dependencies |
| 21 | +RUN pip install --no-cache-dir -e . |
46 | 22 |
|
47 | | -# ------------------------------------------------------------ |
48 | | -# Step 4: Install testing dependencies (optional, for development) |
49 | | -# ------------------------------------------------------------ |
50 | | -RUN pip install --no-cache-dir pytest>=7.4.0 pytest-cov>=4.1.0 |
| 23 | +# Explicit analysis deps (defensive) |
| 24 | +RUN pip install --no-cache-dir pandas scikit-learn matplotlib seaborn |
51 | 25 |
|
52 | | -# Create necessary directories |
53 | 26 | RUN mkdir -p cache logs results |
54 | 27 |
|
55 | | -# Make CLI executable |
56 | | -RUN chmod +x cli.py |
| 28 | +RUN chmod +x cli.py || true |
| 29 | +RUN chmod +x scripts/*.py || true |
57 | 30 |
|
58 | | -# Expose port |
59 | 31 | EXPOSE 8000 |
60 | 32 |
|
61 | | -# Health check |
62 | | -HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ |
63 | | - CMD curl -f http://localhost:8000/health || exit 1 |
64 | | - |
65 | | -# Set PYTHONPATH for app module imports (fixed nested /app/app issue) |
66 | | -# ENV PYTHONPATH=/app:/app/app |
| 33 | +HEALTHCHECK CMD curl -f http://localhost:8000/health || exit 1 |
67 | 34 |
|
68 | | -# Default command (can be overridden) |
69 | 35 | CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "8000"] |
0 commit comments