Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +14 -30
Dockerfile
CHANGED
@@ -1,43 +1,27 @@
|
|
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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
#
|
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 |
EXPOSE 7860
|
41 |
|
42 |
-
|
43 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
1 |
FROM python:3.10.9
|
2 |
|
|
|
3 |
WORKDIR /app
|
4 |
|
|
|
5 |
COPY . /app
|
6 |
|
7 |
+
# Create necessary directories and set permissions only for what we need
|
8 |
+
RUN mkdir -p /app/output && \
|
9 |
+
mkdir -p /app/matplotlib && \
|
10 |
+
mkdir -p /app/ipython && \
|
11 |
+
mkdir -p /app/kernels && \
|
12 |
+
chmod -R 777 /app/output && \
|
13 |
+
chmod -R 777 /app/matplotlib && \
|
14 |
+
chmod -R 777 /app/ipython && \
|
15 |
+
chmod -R 777 /app/kernels
|
16 |
+
|
17 |
+
# Set environment variables
|
18 |
ENV MPLCONFIGDIR=/app/matplotlib
|
|
|
|
|
|
|
|
|
|
|
19 |
ENV IPYTHONDIR=/app/ipython
|
20 |
+
ENV JUPYTER_RUNTIME_DIR=/app/kernels
|
21 |
|
22 |
+
# Install requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
RUN pip install --no-cache-dir -r requirements.txt
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
EXPOSE 7860
|
26 |
|
27 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|