Spaces:
Running
Running
Update Dockerfile
Browse files- 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 |
-
#
|
| 7 |
-
|
| 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 |
-
#
|
| 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 |
-
#
|
|
|
|
|
|
|
| 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 |
-
#
|
| 30 |
-
|
| 31 |
-
RUN pip install --no-cache-dir -r requirements.txt \
|
| 32 |
-
|| (echo "PIP INSTALL FAILED!" && exit 1)
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
RUN chmod -R 755 /app
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
|
| 40 |
-
EXPOSE 8000
|
| 41 |
|
| 42 |
-
# Run the FastAPI app
|
| 43 |
-
|
| 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"]
|
|
|