Create Dockerfile
Browse files- Dockerfile +27 -0
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Create a non-root user and switch to it
|
| 5 |
+
# This is a security best practice and required by some platforms
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV PATH="/home/user/.local/bin:${PATH}"
|
| 9 |
+
|
| 10 |
+
# Set the working directory
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Copy the requirements file and install dependencies
|
| 14 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 15 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
+
|
| 17 |
+
# Copy the application code and saved models
|
| 18 |
+
# The --chown flag ensures the new user owns these files
|
| 19 |
+
COPY --chown=user ./app.py .
|
| 20 |
+
COPY --chown=user ./saved_models ./saved_models
|
| 21 |
+
|
| 22 |
+
# Expose the port the app will run on (Hugging Face default is 7860)
|
| 23 |
+
EXPOSE 7860
|
| 24 |
+
|
| 25 |
+
# Command to run the app when the container launches
|
| 26 |
+
# Note: We use "app:app" because you renamed the file to app.py
|
| 27 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|