leonsimon23 commited on
Commit
b6cc498
·
verified ·
1 Parent(s): 9edf2b5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -11
Dockerfile CHANGED
@@ -4,27 +4,45 @@ FROM python:3.10-slim
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install necessary dependencies
8
- RUN apt-get update && apt-get install -y git
9
-
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Upgrade pip to the latest version
11
  RUN pip install --upgrade pip
12
 
13
- # Create necessary directories and set permissions
14
  RUN mkdir -p /app && chmod -R 777 /app
15
 
16
- # Clone private repository using mounted secret
 
17
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
18
- git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git .
 
19
 
20
- # Copy the static directory into the container
 
21
  COPY static /app/static
22
 
23
- # Install Python dependencies
24
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
25
 
26
- # Expose the port for FastAPI
27
  EXPOSE 7860
28
 
29
- # Run the FastAPI app with uvicorn
30
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # --- Install System Dependencies ---
8
+ # Includes git (for cloning) AND R + R Development tools (for rpy2 and R packages)
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ git \
11
+ r-base \
12
+ r-base-dev \
13
+ && rm -rf /var/lib/apt/lists/* # Clean up apt cache
14
+
15
+ # --- Install Required R Packages ---
16
+ # Install the R packages needed by your R model.
17
+ # *** Modify c('randomForest') if your model depends on other R packages ***
18
+ RUN Rscript -e "install.packages(c('randomForest'), repos='https://cloud.r-project.org/', dependencies=TRUE)" \
19
+ || (echo "R PACKAGE INSTALLATION FAILED" && exit 1) # Basic error check
20
+
21
+ # --- Python Setup ---
22
  # Upgrade pip to the latest version
23
  RUN pip install --upgrade pip
24
 
25
+ # Create necessary directories and set permissions (keeping user's original)
26
  RUN mkdir -p /app && chmod -R 777 /app
27
 
28
+ # --- Application Code ---
29
+ # Clone private repository using mounted secret (keeping user's original)
30
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
31
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
32
+ || (echo "GIT CLONE FAILED!" && exit 1) # Basic error check
33
 
34
+ # Copy the static directory into the container (keeping user's original)
35
+ # Make sure the 'static' directory is available in the build context.
36
  COPY static /app/static
37
 
38
+ # --- Install Python Dependencies ---
39
+ # This MUST run after R is installed so rpy2 can configure correctly.
40
+ # Assumes requirements.txt was cloned via git and includes rpy2.
41
+ RUN pip install --no-cache-dir -r requirements.txt \
42
+ || (echo "PIP INSTALL FAILED!" && exit 1) # Basic error check
43
 
44
+ # Expose the port for FastAPI (keeping user's original)
45
  EXPOSE 7860
46
 
47
+ # Run the FastAPI app with uvicorn (keeping user's original)
48
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]