Spaces:
Runtime error
Runtime error
Commit ·
a4659fb
1
Parent(s): 5606ca5
docker
Browse files- Dockerfile +29 -0
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a lightweight and stable Python 3.11 base image
|
| 2 |
+
FROM python:3.11-slim-buster AS base
|
| 3 |
+
|
| 4 |
+
# Set environment variables for production
|
| 5 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
+
PATH="/home/user/.local/bin:$PATH"
|
| 8 |
+
# Add a non-root user for security
|
| 9 |
+
RUN useradd -m -u 1000 user
|
| 10 |
+
|
| 11 |
+
# Switch to non-root user
|
| 12 |
+
USER user
|
| 13 |
+
|
| 14 |
+
# Set working directory
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
# Install dependencies
|
| 18 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 20 |
+
pip install --no-cache-dir --upgrade -r requirements.txt
|
| 21 |
+
|
| 22 |
+
# Copy application files
|
| 23 |
+
COPY --chown=user . /app
|
| 24 |
+
|
| 25 |
+
# Expose the application port
|
| 26 |
+
EXPOSE 7860
|
| 27 |
+
|
| 28 |
+
# Command to run the application
|
| 29 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4", "--log-level", "info"]
|