Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +13 -20
Dockerfile
CHANGED
|
@@ -11,7 +11,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# --- Install R Packages ---
|
| 14 |
-
# Using tryCatch for basic error checking during R package installation
|
| 15 |
RUN Rscript -e "tryCatch(install.packages(c('randomForest'), repos='https://cloud.r-project.org/', dependencies=TRUE), error=function(e){print(e); q(status=1)})" \
|
| 16 |
&& echo "R packages installed successfully."
|
| 17 |
|
|
@@ -19,45 +18,39 @@ RUN Rscript -e "tryCatch(install.packages(c('randomForest'), repos='https://clou
|
|
| 19 |
RUN pip install --upgrade pip
|
| 20 |
|
| 21 |
# --- Application Code ---
|
| 22 |
-
# Clone repository
|
| 23 |
RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
|
| 24 |
git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
|
| 25 |
-
|| (echo "GIT CLONE FAILED!" && exit 1)
|
| 26 |
|
| 27 |
-
# --- DEBUG: List files in /app AFTER cloning ---
|
| 28 |
-
# This is CRITICAL to see if api.py and requirements.txt are where they should be
|
| 29 |
RUN echo "--- Listing files in /app after clone ---" && ls -la /app
|
| 30 |
|
| 31 |
# --- Install Python Dependencies ---
|
| 32 |
-
# Check if requirements.txt exists before trying to install
|
| 33 |
RUN if [ ! -f requirements.txt ]; then \
|
| 34 |
-
echo "ERROR: requirements.txt not found
|
| 35 |
-
exit 1; \
|
| 36 |
fi
|
| 37 |
-
# Install dependencies
|
| 38 |
RUN pip install --no-cache-dir -r requirements.txt \
|
| 39 |
-
|| (echo "PIP INSTALL FAILED!" && exit 1)
|
| 40 |
|
| 41 |
-
# --- DEBUG: Test
|
| 42 |
-
# Test if R library can be loaded via Rscript
|
| 43 |
RUN echo "--- Testing R library load ---" \
|
| 44 |
&& Rscript -e "library(randomForest)" \
|
| 45 |
|| (echo "ERROR: Failed to load randomForest R library" && exit 1)
|
| 46 |
-
# Test if rpy2 can be imported in Python
|
| 47 |
RUN echo "--- Testing rpy2 import ---" \
|
| 48 |
&& python -c "import rpy2.robjects; print('rpy2 import OK')" \
|
| 49 |
|| (echo "ERROR: Failed to import rpy2 in Python" && exit 1)
|
| 50 |
|
| 51 |
-
# --- DEBUG:
|
| 52 |
-
# This
|
| 53 |
-
RUN echo "---
|
| 54 |
-
&& python -
|
| 55 |
-
|| (echo "ERROR: api.
|
| 56 |
|
| 57 |
-
# Set permissions
|
| 58 |
RUN chmod -R 755 /app
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
# --- Port and Run Command ---
|
| 61 |
-
# Using port 8000 based on api.py, adjust if HF requires 7860
|
| 62 |
EXPOSE 8000
|
| 63 |
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# --- Install R Packages ---
|
|
|
|
| 14 |
RUN Rscript -e "tryCatch(install.packages(c('randomForest'), repos='https://cloud.r-project.org/', dependencies=TRUE), error=function(e){print(e); q(status=1)})" \
|
| 15 |
&& echo "R packages installed successfully."
|
| 16 |
|
|
|
|
| 18 |
RUN pip install --upgrade pip
|
| 19 |
|
| 20 |
# --- Application Code ---
|
|
|
|
| 21 |
RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
|
| 22 |
git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
|
| 23 |
+
|| (echo "GIT CLONE FAILED!" && exit 1)
|
| 24 |
|
|
|
|
|
|
|
| 25 |
RUN echo "--- Listing files in /app after clone ---" && ls -la /app
|
| 26 |
|
| 27 |
# --- Install Python Dependencies ---
|
|
|
|
| 28 |
RUN if [ ! -f requirements.txt ]; then \
|
| 29 |
+
echo "ERROR: requirements.txt not found!"; exit 1; \
|
|
|
|
| 30 |
fi
|
|
|
|
| 31 |
RUN pip install --no-cache-dir -r requirements.txt \
|
| 32 |
+
|| (echo "PIP INSTALL FAILED!" && exit 1)
|
| 33 |
|
| 34 |
+
# --- DEBUG: Test R and rpy2 imports ---
|
|
|
|
| 35 |
RUN echo "--- Testing R library load ---" \
|
| 36 |
&& Rscript -e "library(randomForest)" \
|
| 37 |
|| (echo "ERROR: Failed to load randomForest R library" && exit 1)
|
|
|
|
| 38 |
RUN echo "--- Testing rpy2 import ---" \
|
| 39 |
&& python -c "import rpy2.robjects; print('rpy2 import OK')" \
|
| 40 |
|| (echo "ERROR: Failed to import rpy2 in Python" && exit 1)
|
| 41 |
|
| 42 |
+
# --- DEBUG: Try importing the 'api' module directly with Python ---
|
| 43 |
+
# This will execute the module-level code in api.py and show any import-time errors
|
| 44 |
+
RUN echo "--- Attempting Python import of 'api' module ---" \
|
| 45 |
+
&& python -c "import api; print('SUCCESS: Python successfully imported api module')" \
|
| 46 |
+
|| (echo "ERROR: Python failed to import the 'api' module. Check traceback above." && exit 1)
|
| 47 |
|
| 48 |
+
# Set permissions
|
| 49 |
RUN chmod -R 755 /app
|
| 50 |
|
| 51 |
+
# --- DEBUG: List files right before CMD ---
|
| 52 |
+
RUN echo "--- Listing files in /app before CMD ---" && ls -la /app
|
| 53 |
+
|
| 54 |
# --- Port and Run Command ---
|
|
|
|
| 55 |
EXPOSE 8000
|
| 56 |
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
|