mgbam commited on
Commit
caee626
Β·
verified Β·
1 Parent(s): 7329ecf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -42
Dockerfile CHANGED
@@ -1,52 +1,27 @@
1
- # ─────────────── Stage 1: build Python deps ───────────────
2
- FROM python:3.10-slim AS builder
3
-
4
- ENV PYTHONDONTWRITEBYTECODE=1 \
5
- PYTHONUNBUFFERED=1
6
-
7
- WORKDIR /app
8
-
9
- # basic C / system libs for wheels that need compile
10
- RUN apt-get update && apt-get install -y --no-install-recommends \
11
- build-essential libglib2.0-0 libsm6 libxrender1 libxext6 \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- COPY requirements.txt /
15
- RUN pip install --upgrade pip \
16
- && pip install --no-cache-dir -r /requirements.txt
17
-
18
- # download the small spaCy English model at build-time
19
- RUN python -m spacy download en_core_web_sm
20
-
21
- # ─────────────── Stage 2: runtime image ────────────────────
22
  FROM python:3.10-slim
23
 
24
- # ‼️ fix Streamlit "permission denied /.streamlit" issue
25
- ENV STREAMLIT_DATA_DIR=/tmp/.streamlit \
26
- XDG_STATE_HOME=/tmp \
27
- STREAMLIT_BROWSER_GATHERUSAGESTATS=false
28
-
29
- RUN mkdir -p /tmp/.streamlit
30
 
31
  WORKDIR /app
32
 
33
- RUN apt-get update && apt-get install -y --no-install-recommends \
34
- libglib2.0-0 libsm6 libxrender1 libxext6 \
35
- && rm -rf /var/lib/apt/lists/*
36
 
37
- # copy installed libs from builder
38
- COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
39
- COPY --from=builder /usr/local/bin /usr/local/bin
40
 
41
- # app source
42
- COPY . /app
43
 
44
- # non-root user for security
45
- RUN groupadd -r appuser && useradd -r -g appuser appuser \
46
- && chown -R appuser:appuser /app
47
- USER appuser
 
 
 
 
 
48
 
49
- EXPOSE 7860
50
 
51
- # Streamlit entry
52
- ENTRYPOINT ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.10-slim
2
 
3
+ ENV HOME=/app
4
+ ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
 
 
 
 
5
 
6
  WORKDIR /app
7
 
8
+ COPY requirements.txt .
9
+ RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
 
10
 
11
+ COPY . .
 
 
12
 
13
+ RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
 
14
 
15
+ # Add a default Streamlit config.toml (if you don’t already copy it)
16
+ RUN echo "\
17
+ [server]\n\
18
+ headless = true\n\
19
+ port = 8501\n\
20
+ address = \"0.0.0.0\"\n\
21
+ enableCORS = false\n\
22
+ enableXsrfProtection = false\n\
23
+ " > /app/.streamlit/config.toml
24
 
25
+ EXPOSE 8501
26
 
27
+ CMD streamlit run app.py --server.port=8501 --server.address=0.0.0.0