mgbam commited on
Commit
f733690
·
verified ·
1 Parent(s): 1772663

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -9
Dockerfile CHANGED
@@ -1,28 +1,35 @@
1
- # Enable BuildKit when building: DOCKER_BUILDKIT=1
2
  FROM python:3.10-slim
3
 
 
4
  ENV PYTHONUNBUFFERED=1
5
 
6
  WORKDIR /home/user/app
7
 
8
- # System deps
9
  RUN apt-get update && \
10
  apt-get install -y --no-install-recommends git git-lfs ffmpeg libsm6 libxext6 libgl1-mesa-glx && \
11
  rm -rf /var/lib/apt/lists/* && \
12
  git lfs install
13
 
14
- # Upgrade pip
15
  RUN pip install --no-cache-dir pip setuptools
16
 
17
- # Copy requirements and install
18
  COPY requirements.txt .
 
 
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Copy source
22
  COPY . .
23
 
24
- # Expose Flask port
25
- EXPOSE 8080
26
 
27
- # Run Flask app (no reloader conflict)
28
- CMD ["python", "app.py"]
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1
2
  FROM python:3.10-slim
3
 
4
+ # Prevent Python from buffering stdout/stderr (better logs)
5
  ENV PYTHONUNBUFFERED=1
6
 
7
  WORKDIR /home/user/app
8
 
9
+ # System dependencies (minimal), and Git LFS
10
  RUN apt-get update && \
11
  apt-get install -y --no-install-recommends git git-lfs ffmpeg libsm6 libxext6 libgl1-mesa-glx && \
12
  rm -rf /var/lib/apt/lists/* && \
13
  git lfs install
14
 
15
+ # Upgrade pip/setuptools
16
  RUN pip install --no-cache-dir pip setuptools
17
 
18
+ # Copy requirements early to leverage Docker cache
19
  COPY requirements.txt .
20
+
21
+ # Install Python dependencies
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
+ # Copy application source
25
  COPY . .
26
 
27
+ # Expose both common ports (Flask uses 8080, Streamlit uses 8501)
28
+ EXPOSE 8080 8501
29
 
30
+ # Entrypoint: choose Streamlit if USE_STREAMLIT=1, otherwise run Flask app
31
+ CMD if [ "$USE_STREAMLIT" = "1" ]; then \
32
+ streamlit run app.py --server.port=8501 --server.enableCORS=false; \
33
+ else \
34
+ python app.py; \
35
+ fi