Spaces:
Running
Running
refact: docker update
Browse files- Dockerfile +17 -28
Dockerfile
CHANGED
@@ -1,40 +1,29 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
libgl1 \
|
8 |
-
build-essential \
|
9 |
-
curl \
|
10 |
-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
11 |
-
|
12 |
-
# Create non-root user
|
13 |
RUN useradd -m -u 1000 user
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
PYTHONDONTWRITEBYTECODE=1 \
|
18 |
-
PYTHONUNBUFFERED=1
|
19 |
|
20 |
-
# Switch to
|
21 |
USER user
|
22 |
-
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
|
27 |
-
pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
-
|
30 |
-
RUN python -m spacy download en_core_web_sm || echo "spaCy model download failed, continuing..."
|
31 |
|
32 |
-
|
33 |
-
|
|
|
34 |
|
35 |
-
|
36 |
-
EXPOSE 7860
|
37 |
|
38 |
-
# Start the app
|
39 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
40 |
|
|
|
1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
|
4 |
+
FROM python:3.10
|
5 |
+
|
6 |
+
# Create user first
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
RUN useradd -m -u 1000 user
|
8 |
|
9 |
+
# Install system dependencies (requires root)
|
10 |
+
RUN apt-get update && apt-get install -y libgl1
|
|
|
|
|
11 |
|
12 |
+
# Switch to non-root user
|
13 |
USER user
|
14 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
15 |
|
16 |
+
# Add TensorFlow environment variables to reduce logging noise
|
17 |
+
ENV TF_CPP_MIN_LOG_LEVEL=2
|
18 |
+
ENV TF_ENABLE_ONEDNN_OPTS=0
|
|
|
19 |
|
20 |
+
WORKDIR /app
|
|
|
21 |
|
22 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
23 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
24 |
+
RUN python -m spacy download en_core_web_sm || echo "Failed to download model"
|
25 |
|
26 |
+
COPY --chown=user . /app
|
|
|
27 |
|
|
|
28 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
29 |
|