File size: 1,656 Bytes
c6240ca f797a9e c6240ca f16d0f1 4484e38 c6240ca f797a9e c6240ca f797a9e c6240ca f16d0f1 c6240ca 4484e38 f797a9e c6240ca b493000 c6240ca b493000 c6240ca f16d0f1 4484e38 f797a9e 4484e38 c6240ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# βββββββββββββββ Stage 1: build Python deps βββββββββββββββ
FROM python:3.10-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
# basic C / system libs for wheels that need compile
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt /
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r /requirements.txt
# download the small spaCy English model at build-time
RUN python -m spacy download en_core_web_sm
# βββββββββββββββ Stage 2: runtime image ββββββββββββββββββββ
FROM python:3.10-slim
# βΌοΈ fix Streamlit "permission denied /.streamlit" issue
ENV STREAMLIT_DATA_DIR=/tmp/.streamlit \
XDG_STATE_HOME=/tmp \
STREAMLIT_BROWSER_GATHERUSAGESTATS=false
RUN mkdir -p /tmp/.streamlit
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
# copy installed libs from builder
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# app source
COPY . /app
# non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser \
&& chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
# Streamlit entry
ENTRYPOINT ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=7860"]
|