Spaces:
Running
Running
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.9-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /code
|
| 6 |
+
|
| 7 |
+
# Copy the requirements file into the container
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install any needed packages specified in requirements.txt
|
| 11 |
+
# Using --no-cache-dir reduces image size
|
| 12 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 13 |
+
pip install --no-cache-dir -r requirements.txt
|
| 14 |
+
|
| 15 |
+
# Copy the Flask application code into the container
|
| 16 |
+
COPY app.py .
|
| 17 |
+
|
| 18 |
+
# Make port 7860 available to the world outside this container
|
| 19 |
+
# This is the port Hugging Face Spaces expects by default for web apps
|
| 20 |
+
EXPOSE 7860
|
| 21 |
+
|
| 22 |
+
# Define environment variable for Flask (optional but good practice)
|
| 23 |
+
# ENV FLASK_APP=app.py # Not strictly needed when using `flask run` like below
|
| 24 |
+
|
| 25 |
+
# Command to run the application when the container launches
|
| 26 |
+
# Use 'flask run' for development/simple cases. For production, gunicorn is often preferred.
|
| 27 |
+
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
|