Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +32 -12
Dockerfile
CHANGED
|
@@ -1,21 +1,41 @@
|
|
| 1 |
-
# Use an official Python runtime as
|
| 2 |
-
FROM python:3.9
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.10.9
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy the current directory contents into the container at /app
|
| 8 |
+
COPY . /app
|
| 9 |
|
| 10 |
+
# Set environment variable for Matplotlib to use a writable directory
|
| 11 |
+
ENV MPLCONFIGDIR=/app/matplotlib
|
| 12 |
|
| 13 |
+
# Create the directory for Matplotlib config and set write permissions
|
| 14 |
+
RUN mkdir -p /app/matplotlib && chmod -R 777 /app/matplotlib
|
| 15 |
+
|
| 16 |
+
# Set environment variable for IPython to use a writable directory
|
| 17 |
+
ENV IPYTHONDIR=/app/ipython
|
| 18 |
+
|
| 19 |
+
# Create the directory for IPython config and set write permissions
|
| 20 |
+
RUN mkdir -p /app/ipython && chmod -R 777 /app/ipython
|
| 21 |
+
|
| 22 |
+
# Create an output folder and give it all permissions
|
| 23 |
+
RUN mkdir -p /app/output && chmod -R 2777 /app/output
|
| 24 |
+
|
| 25 |
+
# Install any needed packages specified in requirements.txt
|
| 26 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 27 |
|
| 28 |
+
# Run the script to download NLTK data
|
| 29 |
+
# RUN python /app/download_nltk_data.py
|
| 30 |
+
|
| 31 |
+
# Create a non-root user
|
| 32 |
+
RUN useradd -m myuser
|
| 33 |
+
|
| 34 |
+
# Change the owner of the application directory
|
| 35 |
+
RUN chown -R myuser:myuser /app
|
| 36 |
+
|
| 37 |
+
# Switch to the non-root user
|
| 38 |
+
USER myuser
|
| 39 |
|
| 40 |
+
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
| 41 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|