Update Dockerfile
Browse files- Dockerfile +15 -6
Dockerfile
CHANGED
|
@@ -1,15 +1,24 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
EXPOSE 7860
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# Set the working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Create a non-root user and switch to it
|
| 7 |
+
RUN useradd -m appuser
|
| 8 |
+
USER appuser
|
| 9 |
|
| 10 |
+
# Set the Hugging Face home directory to a user-owned path
|
| 11 |
+
ENV HF_HOME=/home/appuser/.cache/huggingface
|
| 12 |
|
| 13 |
+
# Copy the requirements file and install dependencies
|
| 14 |
+
COPY --chown=appuser:appuser requirements.txt .
|
| 15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
+
# Copy the application code
|
| 18 |
+
COPY --chown=appuser:appuser app.py .
|
| 19 |
+
|
| 20 |
+
# Expose the port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# Set the default command to run the application
|
| 24 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|