pvanand commited on
Commit
823b7be
1 Parent(s): d49d439

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -0
Dockerfile ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 requirements.txt /app
8
+
9
+ # Install any needed packages specified in requirements.txt
10
+ RUN pip install --no-cache-dir -r requirements.txt
11
+
12
+ # Create a non-root user
13
+ RUN useradd -m appuser
14
+
15
+ # Create necessary directories and set permissions
16
+ RUN mkdir -p /app/data && \
17
+ chown -R appuser:appuser /app && \
18
+ chmod -R 755 /app && \
19
+ mkdir -p /tmp/app-work && \
20
+ chown -R appuser:appuser /tmp/app-work && \
21
+ chmod -R 777 /tmp/app-work
22
+
23
+ # Switch to the non-root user
24
+ USER appuser
25
+
26
+ # Copy the current directory contents into the container at /app
27
+ COPY . /app
28
+
29
+ # Start the FastAPI app on port 7860, the default port expected by Spaces
30
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]