Upload 2 files
Browse files- Dockerfile +24 -0
- README-HUGGINGFACE.md +35 -0
Dockerfile
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
# Copy requirements first for better caching
|
6 |
+
COPY requirements.txt .
|
7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
8 |
+
|
9 |
+
# Copy application code
|
10 |
+
COPY . .
|
11 |
+
|
12 |
+
# Create uploads directory
|
13 |
+
RUN mkdir -p uploads
|
14 |
+
|
15 |
+
# Set environment variables
|
16 |
+
ENV PORT=7860
|
17 |
+
ENV PYTHONUNBUFFERED=1
|
18 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
19 |
+
|
20 |
+
# Expose the port
|
21 |
+
EXPOSE 7860
|
22 |
+
|
23 |
+
# Command to run the application
|
24 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|
README-HUGGINGFACE.md
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Deploying on Hugging Face Spaces
|
2 |
+
|
3 |
+
This document provides instructions for deploying this Flask application on Hugging Face Spaces.
|
4 |
+
|
5 |
+
## Deployment Steps
|
6 |
+
|
7 |
+
1. Create a new Space on Hugging Face:
|
8 |
+
- Go to https://huggingface.co/spaces
|
9 |
+
- Click "Create new Space"
|
10 |
+
- Choose "Docker" as the Space SDK
|
11 |
+
- Fill in the required details (name, visibility, etc.)
|
12 |
+
|
13 |
+
2. Upload your code:
|
14 |
+
- You can use Git to push your code to the Space repository
|
15 |
+
- Make sure to include all necessary files (app.py, requirements.txt, Dockerfile, etc.)
|
16 |
+
|
17 |
+
3. The Space will automatically build and deploy your application using the provided Dockerfile.
|
18 |
+
|
19 |
+
## Important Notes
|
20 |
+
|
21 |
+
- The application is configured to run on port 7860, which is the default port for Hugging Face Spaces
|
22 |
+
- Make sure your .env file is properly configured with any required API keys
|
23 |
+
- The uploads directory is created automatically during the Docker build process
|
24 |
+
- The application uses gunicorn as the WSGI server for production deployment
|
25 |
+
|
26 |
+
## Environment Variables
|
27 |
+
|
28 |
+
If your application requires API keys or other sensitive information, you should set them as environment variables in your Hugging Face Space settings rather than including them in your code repository.
|
29 |
+
|
30 |
+
## Troubleshooting
|
31 |
+
|
32 |
+
If you encounter any issues with the deployment:
|
33 |
+
1. Check the build logs in your Hugging Face Space
|
34 |
+
2. Verify that all required files are included in your repository
|
35 |
+
3. Make sure your application is properly configured to run on port 7860
|