Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +45 -0
Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Base image with CUDA for ML
|
| 2 |
+
FROM nvidia/cuda:12.2.0-base-ubuntu22.04
|
| 3 |
+
|
| 4 |
+
# π οΈ Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
python3.11 \
|
| 7 |
+
python3.11-dev \
|
| 8 |
+
python3-pip \
|
| 9 |
+
build-essential \
|
| 10 |
+
curl \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 12 |
+
&& apt-get clean
|
| 13 |
+
|
| 14 |
+
# π Set Python 3.11 as default
|
| 15 |
+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \
|
| 16 |
+
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
| 17 |
+
|
| 18 |
+
# π Set working directory
|
| 19 |
+
WORKDIR /home/user/app
|
| 20 |
+
|
| 21 |
+
# π Install Python dependencies
|
| 22 |
+
COPY ./requirements.txt .
|
| 23 |
+
RUN pip install --no-cache-dir --upgrade pip \
|
| 24 |
+
&& pip install --no-cache-dir -r requirements.txt \
|
| 25 |
+
&& pip install --no-cache-dir \
|
| 26 |
+
https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl \
|
| 27 |
+
https://huggingface.co/spacy/en_core_web_lg/resolve/main/en_core_web_lg-any-py3-none-any.whl
|
| 28 |
+
|
| 29 |
+
# π Create non-root user
|
| 30 |
+
RUN useradd -m -u 1000 user
|
| 31 |
+
USER user
|
| 32 |
+
ENV HOME=/home/user \
|
| 33 |
+
PATH=/home/user/.local/bin:$PATH
|
| 34 |
+
|
| 35 |
+
# π¦ Copy application code
|
| 36 |
+
COPY --chown=user . .
|
| 37 |
+
|
| 38 |
+
# π Expose port
|
| 39 |
+
EXPOSE 7860
|
| 40 |
+
|
| 41 |
+
# π©Ί Healthcheck
|
| 42 |
+
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
|
| 43 |
+
|
| 44 |
+
# π Run application
|
| 45 |
+
CMD ["python3", "-m", "streamlit", "run", "presidio_streamlit.py", "--server.port=7860", "--server.address=0.0.0.0"]
|