Update Dockerfile
Browse files- Dockerfile +11 -5
Dockerfile
CHANGED
@@ -22,16 +22,22 @@ COPY . .
|
|
22 |
# Expose the FastAPI port
|
23 |
EXPOSE 7860
|
24 |
|
|
|
25 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
26 |
PYTHONUNBUFFERED=1 \
|
27 |
-
XDG_CACHE_HOME=/app/.cache
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
chmod -R 777 /app
|
32 |
|
33 |
RUN pip install spacy && python -m spacy download en_core_web_sm
|
34 |
-
USER
|
35 |
|
36 |
# Start the FastAPI app
|
37 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
22 |
# Expose the FastAPI port
|
23 |
EXPOSE 7860
|
24 |
|
25 |
+
# Environment variables to control Python and caching behavior.
|
26 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
27 |
PYTHONUNBUFFERED=1 \
|
28 |
+
XDG_CACHE_HOME=/app/.cache \
|
29 |
+
HF_HOME=/app/.cache/huggingface \
|
30 |
+
PIP_ROOT_USER_ACTION=ignore
|
31 |
+
|
32 |
+
# Create a non-root user and set up directories with wide permissions.
|
33 |
+
RUN adduser --disabled-password --gecos '' appuser && \
|
34 |
+
mkdir -p /app/.cache/huggingface/hub && \
|
35 |
+
mkdir -p /app/.local && \
|
36 |
+
chown -R appuser:appuser /app && \
|
37 |
chmod -R 777 /app
|
38 |
|
39 |
RUN pip install spacy && python -m spacy download en_core_web_sm
|
40 |
+
USER appuser
|
41 |
|
42 |
# Start the FastAPI app
|
43 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|