Create Dockerfile
Browse files- Dockerfile +26 -0
Dockerfile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official lightweight Python image.
|
| 2 |
+
# https://hub.docker.com/_/python
|
| 3 |
+
FROM python:3.9-slim
|
| 4 |
+
|
| 5 |
+
# Set the working directory to /app
|
| 6 |
+
WORKDIR /app
|
| 7 |
+
|
| 8 |
+
# Create a non-root user with an explicit UID and adds permission to access the /app folder
|
| 9 |
+
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
|
| 10 |
+
RUN adduser -u 1000 --disabled-password --gecos "" appuser && chown -R appuser /app
|
| 11 |
+
USER appuser
|
| 12 |
+
|
| 13 |
+
# Copy the requirements file into the container
|
| 14 |
+
COPY --chown=appuser requirements.txt .
|
| 15 |
+
|
| 16 |
+
# Install the dependencies
|
| 17 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 18 |
+
|
| 19 |
+
# Copy the rest of the application code
|
| 20 |
+
COPY --chown=appuser . .
|
| 21 |
+
|
| 22 |
+
# Expose the port that Hugging Face Spaces expects (7860)
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
|
| 25 |
+
# Command to run the application using uvicorn
|
| 26 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|