themehmi commited on
Commit
babaae6
·
verified ·
1 Parent(s): f1ca991

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -12
Dockerfile CHANGED
@@ -1,23 +1,27 @@
1
  # Use an official lightweight Python image
2
  FROM python:3.11-slim
3
 
4
- # Set the working directory inside the container
5
- WORKDIR /app
 
6
 
7
- # Copy the requirements file first to leverage Docker cache
8
- COPY requirements.txt .
 
 
9
 
10
- # Install dependencies
 
 
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Copy the rest of your application code
14
- COPY . .
15
 
16
- # Expose port 7860
17
  EXPOSE 7860
18
 
19
- # Set environment variables so Python outputs straight to the terminal
20
- ENV PYTHONUNBUFFERED=1
21
-
22
- # Command to run your attendance system
23
- CMD ["python", "app.py"]
 
1
  # Use an official lightweight Python image
2
  FROM python:3.11-slim
3
 
4
+ # Create a non-root user (Required by Hugging Face Spaces)
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
 
8
+ # Set environment variables
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH \
11
+ PYTHONUNBUFFERED=1
12
 
13
+ # Set the working directory
14
+ WORKDIR $HOME/app
15
+
16
+ # Copy requirements and install them
17
+ COPY --chown=user requirements.txt .
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
  # Copy the rest of your application code
21
+ COPY --chown=user . .
22
 
23
+ # Hugging Face routes traffic to port 7860
24
  EXPOSE 7860
25
 
26
+ # Run the application using Gunicorn
27
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]