leonsimon23 commited on
Commit
b4152fb
·
verified ·
1 Parent(s): 9c7a67f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -27
Dockerfile CHANGED
@@ -1,45 +1,44 @@
1
  # syntax=docker/dockerfile:1.4
2
  FROM python:3.10-slim
3
 
 
4
  WORKDIR /app
5
 
6
- # --- Install System Dependencies ---
7
- RUN apt-get update && apt-get install -y --no-install-recommends \
8
  git \
 
 
 
 
 
9
  r-base \
10
- r-base-dev \
11
- # May need additional system libraries for tidymodels dependencies, e.g.:
12
- libcurl4-openssl-dev \
13
- libssl-dev \
14
- libxml2-dev \
15
- && rm -rf /var/lib/apt/lists/*
16
-
17
- # --- Install Required R Packages ---
18
- # *** ADDED tidymodels package ***
19
- RUN Rscript -e "install.packages(c('randomForest', 'tidymodels'), repos='https://cloud.r-project.org/', dependencies=TRUE)" \
20
- || (echo "R PACKAGE INSTALLATION FAILED" && exit 1)
21
-
22
- # --- Python Setup ---
23
  RUN pip install --upgrade pip
24
 
25
- # Create directories and set permissions
26
  RUN mkdir -p /app && chmod -R 777 /app
27
 
28
- # --- Application Code ---
29
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
30
- git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
31
- || (echo "GIT CLONE FAILED!" && exit 1)
32
 
33
- # Copy static directory
34
  COPY static /app/static
35
 
36
- # --- Install Python Dependencies ---
37
- # Ensure requirements.txt includes rpy2, pandas, fastapi, uvicorn etc.
38
- RUN pip install --no-cache-dir -r requirements.txt \
39
- || (echo "PIP INSTALL FAILED!" && exit 1)
 
40
 
41
- # Expose port
42
  EXPOSE 7860
43
 
44
- # Run the FastAPI app
45
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # syntax=docker/dockerfile:1.4
2
  FROM python:3.10-slim
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install necessary dependencies including R and libraries for rpy2
8
+ RUN apt-get update && apt-get install -y \
9
  git \
10
+ curl \
11
+ apt-transport-https \
12
+ ca-certificates \
13
+ gnupg \
14
+ lsb-release \
15
  r-base \
16
+ r-cran-rpy2 # Install R and the rpy2 dependency for Python
17
+
18
+ # Install R packages (if needed, such as data.table, caret, etc. for model handling)
19
+ RUN R -e "install.packages('data.table')" # Example, add other R dependencies if needed
20
+
21
+ # Upgrade pip to the latest version
 
 
 
 
 
 
 
22
  RUN pip install --upgrade pip
23
 
24
+ # Create necessary directories and set permissions
25
  RUN mkdir -p /app && chmod -R 777 /app
26
 
27
+ # Clone the private repository using the mounted secret (Ensure GITHUB_TOKEN is correctly set)
28
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
29
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git .
 
30
 
31
+ # Copy static directory into the container (if exists)
32
  COPY static /app/static
33
 
34
+ # Copy the necessary files for model loading and app execution
35
+ COPY rf_model.rds /app/rf_model.rds # Ensure that the .rds model is copied into the container
36
+
37
+ # Install Python dependencies
38
+ RUN pip install --no-cache-dir -r requirements.txt
39
 
40
+ # Expose the port for FastAPI
41
  EXPOSE 7860
42
 
43
+ # Run the FastAPI app with uvicorn
44
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]