Spaces:
Sleeping
Sleeping
CHRISDANIEL145
commited on
Commit
·
68686af
1
Parent(s):
ab60b70
Configure for Hugging Face Spaces deployment
Browse files- Dockerfile +34 -0
- requirements.txt +0 -0
- run.py +5 -2
Dockerfile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Set working directory
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Install system dependencies (gcc for some python packages)
|
| 7 |
+
RUN apt-get update && apt-get install -y \
|
| 8 |
+
gcc \
|
| 9 |
+
g++ \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# Copy requirements first to leverage cache
|
| 13 |
+
COPY requirements.txt .
|
| 14 |
+
|
| 15 |
+
# Install dependencies
|
| 16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
+
RUN python -m spacy download en_core_web_sm
|
| 18 |
+
|
| 19 |
+
# Copy the rest of the application
|
| 20 |
+
COPY . .
|
| 21 |
+
|
| 22 |
+
# Create a directory for the database in a writable location if needed,
|
| 23 |
+
# or ensure the current directory is writable.
|
| 24 |
+
# HF Spaces usually run as user 1000.
|
| 25 |
+
RUN chmod -R 777 /app
|
| 26 |
+
|
| 27 |
+
# Environment variables
|
| 28 |
+
ENV PORT=7860
|
| 29 |
+
|
| 30 |
+
# Expose the port (optional metadata)
|
| 31 |
+
EXPOSE 7860
|
| 32 |
+
|
| 33 |
+
# Run the application
|
| 34 |
+
CMD ["python", "run.py"]
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|
run.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
# Import the create_app function from your app.py
|
| 4 |
from app import create_app
|
|
@@ -14,4 +14,7 @@ if __name__ == "__main__":
|
|
| 14 |
# debug=True enables reloader and debugger, useful during development
|
| 15 |
# host='0.0.0.0' makes the server accessible from other devices on the network
|
| 16 |
# port=5000 is the default Flask port
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
|
| 3 |
# Import the create_app function from your app.py
|
| 4 |
from app import create_app
|
|
|
|
| 14 |
# debug=True enables reloader and debugger, useful during development
|
| 15 |
# host='0.0.0.0' makes the server accessible from other devices on the network
|
| 16 |
# port=5000 is the default Flask port
|
| 17 |
+
# Create the database in a writable location if needed (e.g., /tmp/history.db for read-only systems)
|
| 18 |
+
# For now, we keep it local, but ensure the folder is writable in Docker
|
| 19 |
+
port = int(os.environ.get("PORT", 7860))
|
| 20 |
+
app.run(debug=False, host='0.0.0.0', port=port)
|