pvanand commited on
Commit
bdf5172
·
verified ·
1 Parent(s): 73d8d5f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -12
Dockerfile CHANGED
@@ -1,21 +1,41 @@
1
- # Use an official Python runtime as the base image
2
- FROM python:3.9-slim
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Install git
8
- RUN apt-get update && apt-get install -y git
9
 
10
- # Clone the repository
11
- RUN git clone https://github.com/pvanand07/flask-web-server-with-auth.git .
12
 
13
- # Install the required packages
 
 
 
 
 
 
 
 
 
 
 
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Expose the port the app runs on
17
- # Required: Update port number on Readme.md
18
- EXPOSE 7860
 
 
 
 
 
 
 
 
19
 
20
- # Run the application
21
- CMD ["python", "main.py"]
 
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"]