Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +31 -30
Dockerfile
CHANGED
|
@@ -1,30 +1,31 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.9-slim
|
| 3 |
-
|
| 4 |
-
# Set the working directory in the container
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Copy the requirements file into the container
|
| 8 |
-
COPY requirements.txt .
|
| 9 |
-
|
| 10 |
-
# Install any needed packages specified in requirements.txt
|
| 11 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
-
|
| 13 |
-
# Copy the current directory contents into the container at /app
|
| 14 |
-
COPY . .
|
| 15 |
-
|
| 16 |
-
# Make port 7860 available (Hugging Face Default)
|
| 17 |
-
EXPOSE 7860
|
| 18 |
-
|
| 19 |
-
# Define environment variable
|
| 20 |
-
ENV FLASK_APP=backend/main.py
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
#
|
| 30 |
-
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy the requirements file into the container
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install any needed packages specified in requirements.txt
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Copy the current directory contents into the container at /app
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Make port 7860 available (Hugging Face Default)
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
# Define environment variable
|
| 20 |
+
ENV FLASK_APP=backend/main.py
|
| 21 |
+
ENV PYTHONPATH=/app/backend
|
| 22 |
+
|
| 23 |
+
# Create a non-root user (Security Best Practice for Spaces)
|
| 24 |
+
RUN useradd -m -u 1000 user
|
| 25 |
+
USER user
|
| 26 |
+
ENV HOME=/home/user \
|
| 27 |
+
PATH=/home/user/.local/bin:$PATH
|
| 28 |
+
|
| 29 |
+
# Run gunicorn
|
| 30 |
+
# Hugging Face expects port 7860
|
| 31 |
+
CMD gunicorn --workers=${WEB_CONCURRENCY:-4} --bind=0.0.0.0:${PORT:-7860} backend.main:app
|