File size: 1,764 Bytes
0ca81fc f16d0f1 0ca81fc 2321094 4232e86 2321094 0ca81fc 2321094 0ca81fc 2321094 0ca81fc 2321094 0ca81fc caee626 0ca81fc dad49da 0ca81fc dad49da f797a9e 0ca81fc caee626 b493000 0ca81fc 2321094 4484e38 0ca81fc |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# --------------------
# Base image & metadata
# --------------------
FROM python:3.10-slim
LABEL maintainer="Your Name <[email protected]>" \
description="Streamlit app with spaCy, CPU-only, for Hugging Face Space"
# --------------------
# Environment variables
# --------------------
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PORT=7860 \
HOME=/code \
STREAMLIT_HOME=/code/.streamlit \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_SERVER_ENABLECORS=false \
STREAMLIT_SERVER_ENABLEWEBRTC=false \
STREAMLIT_SERVER_PORT=7860
# --------------------
# Working directory
# --------------------
WORKDIR /code
# --------------------
# System dependencies
# --------------------
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*
# --------------------
# Python dependencies
# --------------------
COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel \
&& pip install -r requirements.txt
# --------------------
# spaCy English model
# --------------------
RUN python -m spacy download en_core_web_sm
# --------------------
# Copy application code
# --------------------
COPY . .
# --------------------
# Expose port
# --------------------
EXPOSE 7860
# --------------------
# Create non-root user (optional but recommended)
# --------------------
ARG USER_UID=1000
ARG USER_GID=1000
RUN groupadd --gid "$USER_GID" appgroup \
&& useradd --uid "$USER_UID" --gid appgroup --shell /bin/false --no-create-home appuser \
&& chown -R appuser:appgroup /code
USER appuser
# --------------------
# Entrypoint
# --------------------
ENTRYPOINT ["streamlit", "run", "app.py"]
CMD ["--server.address=0.0.0.0", "--server.port=7860"]
|