Spaces:
Sleeping
Sleeping
Commit ·
3506d71
1
Parent(s): defd73b
Add HuggingFace Spaces Docker deployment config
Browse files- .dockerignore +9 -0
- Dockerfile +30 -0
- backend/app.py +4 -2
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
frontend/node_modules
|
| 3 |
+
backend/venv
|
| 4 |
+
backend/__pycache__
|
| 5 |
+
notebooks
|
| 6 |
+
*.ipynb
|
| 7 |
+
.git
|
| 8 |
+
render.yaml
|
| 9 |
+
build.sh
|
Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
# Install Node.js for React build
|
| 4 |
+
RUN apt-get update && apt-get install -y curl && \
|
| 5 |
+
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
|
| 6 |
+
apt-get install -y nodejs && \
|
| 7 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
# Install Python dependencies
|
| 12 |
+
COPY backend/requirements.txt backend/requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir -r backend/requirements.txt
|
| 14 |
+
|
| 15 |
+
# Build React frontend
|
| 16 |
+
COPY frontend/package.json frontend/package-lock.json frontend/
|
| 17 |
+
RUN cd frontend && npm install
|
| 18 |
+
|
| 19 |
+
COPY frontend/ frontend/
|
| 20 |
+
RUN cd frontend && npm run build
|
| 21 |
+
|
| 22 |
+
# Copy backend and datasets
|
| 23 |
+
COPY backend/ backend/
|
| 24 |
+
COPY datasets/ datasets/
|
| 25 |
+
|
| 26 |
+
# HuggingFace Spaces requires port 7860
|
| 27 |
+
ENV PORT=7860
|
| 28 |
+
EXPOSE 7860
|
| 29 |
+
|
| 30 |
+
CMD ["python", "backend/app.py"]
|
backend/app.py
CHANGED
|
@@ -176,7 +176,9 @@ def not_found(e):
|
|
| 176 |
return app.send_static_file('index.html')
|
| 177 |
|
| 178 |
if __name__ == '__main__':
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
print(f"CSV file: {CSV_FILE}")
|
| 181 |
print(f"Default weights: {DEFAULT_WEIGHTS}")
|
| 182 |
-
app.run(debug=
|
|
|
|
| 176 |
return app.send_static_file('index.html')
|
| 177 |
|
| 178 |
if __name__ == '__main__':
|
| 179 |
+
port = int(os.environ.get('PORT', 5005))
|
| 180 |
+
debug = os.environ.get('RENDER') is None # debug mode only locally
|
| 181 |
+
print(f"Starting Flask server on http://0.0.0.0:{port}")
|
| 182 |
print(f"CSV file: {CSV_FILE}")
|
| 183 |
print(f"Default weights: {DEFAULT_WEIGHTS}")
|
| 184 |
+
app.run(debug=debug, port=port, host='0.0.0.0')
|