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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -30
Dockerfile CHANGED
@@ -1,44 +1,30 @@
1
  # syntax=docker/dockerfile:1.4
2
  FROM python:3.10-slim
3
 
 
4
  WORKDIR /app
5
 
6
- # --- Install System Dependencies ---
7
- # Includes git (for cloning), R, and R development tools
8
- RUN apt-get update && apt-get install -y --no-install-recommends \
9
- git \
10
- r-base \
11
- r-base-dev \
12
- && rm -rf /var/lib/apt/lists/*
13
 
14
- # --- Install R Packages ---
15
- # Install the R packages required by your model (adjust if needed)
16
- RUN Rscript -e "install.packages(c('randomForest'), repos='https://cloud.r-project.org/', dependencies=TRUE)"
17
-
18
- # --- Python Setup ---
19
- # Upgrade pip
20
  RUN pip install --upgrade pip
21
 
22
- # --- Application Code ---
 
 
23
  # Clone private repository using mounted secret
24
- # Assumes app.py, requirements.txt, rf_model.rds are in the repo root
25
  RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
26
- git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/pdpredict.git . \
27
- || (echo "GIT CLONE FAILED!" && exit 1)
28
 
29
- # --- Install Python Dependencies ---
30
- # Install Python requirements from file cloned via git
31
- RUN pip install --no-cache-dir -r requirements.txt \
32
- || (echo "PIP INSTALL FAILED!" && exit 1)
33
 
34
- # --- Permissions ---
35
- # Optional, but can help prevent permission issues in some environments
36
- RUN chmod -R 755 /app
37
 
38
- # --- Port and Run Command ---
39
- # Expose the port (Using 8000, change to 7860 if required by Hugging Face Spaces)
40
- EXPOSE 8000
41
 
42
- # Run the FastAPI app defined in app.py (app:app) using uvicorn
43
- # Using port 8000, change to 7860 if required by Hugging Face Spaces
44
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
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
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"]