Man0707 commited on
Commit
e38c8a9
·
verified ·
1 Parent(s): 4671783

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -11
Dockerfile CHANGED
@@ -1,20 +1,32 @@
1
- FROM python:3.13.5-slim
 
2
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
 
10
 
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
14
- RUN pip3 install -r requirements.txt
 
 
15
 
 
16
  EXPOSE 8501
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
1
+ # Use lightweight official Python image
2
+ FROM python:3.11-slim
3
 
4
+ # Prevent Python from writing .pyc files and enable buffering
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+
8
+ # Set working directory inside container
9
  WORKDIR /app
10
 
11
+ # Copy only requirements first (best practice for caching)
12
+ COPY requirements.txt .
13
+
14
+ # Install dependencies (fast & clean)
15
+ RUN pip install --no-cache-dir --upgrade pip && \
16
+ pip install --no-cache-dir -r requirements.txt
17
 
18
+ # Copy your entire app (code + model files)
19
+ COPY . .
20
 
21
+ # Create a non-root user (security best practice)
22
+ RUN useradd -m appuser && chown -R appuser:appuser /app
23
+ USER appuser
24
 
25
+ # Expose Streamlit port
26
  EXPOSE 8501
27
 
28
+ # Health check (optional but recommended)
29
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
30
 
31
+ # Run Streamlit app
32
+ CMD ["streamlit", "run", "mushroom_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]