leonsimon23 commited on
Commit
da4b4c2
·
verified ·
1 Parent(s): 114085d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -37
Dockerfile CHANGED
@@ -1,45 +1,19 @@
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
-
38
- # Install Python dependencies
39
- RUN pip install --no-cache-dir -r requirements.txt
40
-
41
- # Expose the port for FastAPI
42
  EXPOSE 7860
43
-
44
- # Run the FastAPI app with uvicorn
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
  WORKDIR /app
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ git r-base r-base-dev libcurl4-openssl-dev libssl-dev libxml2-dev \
6
+ && rm -rf /var/lib/apt/lists/*
7
+ # Installs tidymodels (which includes workflows, parsnip etc) and randomForest engine
8
+ RUN Rscript -e "install.packages(c('tidymodels', 'randomForest'), repos='https://cloud.r-project.org/', dependencies=TRUE)" \
9
+ || (echo "R PACKAGE INSTALLATION FAILED" && exit 1)
 
 
 
 
 
 
 
 
 
 
10
  RUN pip install --upgrade pip
 
 
11
  RUN mkdir -p /app && chmod -R 777 /app
 
 
12
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
13
+ git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
14
+ || (echo "GIT CLONE FAILED!" && exit 1)
 
15
  COPY static /app/static
16
+ RUN pip install --no-cache-dir -r requirements.txt \
17
+ || (echo "PIP INSTALL FAILED!" && exit 1)
 
 
 
 
 
 
 
18
  EXPOSE 7860
19
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]