vinhngba2704 commited on
Commit
fed24a3
·
1 Parent(s): 9576c0f

Add Dockerfile and .dockerignore

Browse files
Files changed (2) hide show
  1. .dockerignore +2 -0
  2. Dockerfile +32 -0
.dockerignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Ignore Python cache
2
+ __pycache__/
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.11 slim base image
2
+ FROM python:3.11-slim
3
+
4
+ # Create new user with UID 1000, avoid permission issues and improves security
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # Set working directory inside the container
9
+ WORKDIR /app
10
+
11
+ # Copy requirements.txt into the container and ensures the non-root user (user) owns the file
12
+ COPY --chown=user requirements.txt requirements.txt
13
+
14
+ # Install dependencies from requirements.txt
15
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
16
+
17
+ # Copy entire project code into container at /app
18
+ COPY --chown=user . /app
19
+
20
+ # Environment Variables
21
+ # HEADLESS=true: Run Streamlit in headless mode (no browser popup)
22
+
23
+ # ENABLECORS=false: Disables CORS checks (important for Spaces)
24
+
25
+ # PORT=7860: Spaces use this port for the web UI
26
+
27
+
28
+ ENV STREAMLIT_SERVER_HEADLESS=true
29
+ ENV STREAMLIT_SERVER_ENABLECORS=false
30
+ ENV STREAMLIT_SERVER_PORT=7860
31
+
32
+ CMD ["streamlit", "run", "app.py"]