NavyDevilDoc commited on
Commit
fb3695d
·
verified ·
1 Parent(s): bd24dbd

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -0
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official lightweight Python image.
2
+ FROM python:3.11-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+
8
+ # Create a non-root user (Recommended for HF Spaces security permissions)
9
+ RUN useradd -m -u 1000 user
10
+ USER user
11
+ ENV PATH="/home/user/.local/bin:$PATH"
12
+
13
+ # Set the working directory in the container
14
+ WORKDIR /app
15
+
16
+ # Copy the requirements file first to leverage Docker cache
17
+ # Note the --chown flag to ensure the non-root user owns the files
18
+ COPY --chown=user ./requirements.txt requirements.txt
19
+
20
+ # Install dependencies
21
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
22
+
23
+ # Copy the rest of the application code
24
+ COPY --chown=user . /app
25
+
26
+ # Expose the port strictly required by Hugging Face Spaces
27
+ EXPOSE 7860
28
+
29
+ # Healthcheck updated to check the correct port
30
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
31
+
32
+ # Command to run the application
33
+ # Note the addition of --server.port=7860
34
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]