AliHashir commited on
Commit
148e05f
·
1 Parent(s): 3b8b303

feat: add Dockerfile for deployment on Hugging Face Spaces

Browse files
Files changed (2) hide show
  1. Dockerfile +26 -0
  2. README.md +23 -5
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+ ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1
7
+
8
+ # System deps: keep minimal (wheels cover lxml/torch on linux x86_64)
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ COPY requirements.txt /app/requirements.txt
13
+ RUN python -m pip install --upgrade pip && pip install -r requirements.txt
14
+
15
+ COPY . /app
16
+
17
+ # Set cache paths for faster cold starts on Spaces
18
+ ENV HF_HOME=/tmp/.huggingface \
19
+ TRANSFORMERS_CACHE=/tmp/.cache/huggingface \
20
+ SENTENCE_TRANSFORMERS_HOME=/tmp/.cache/sentence-transformers
21
+
22
+ # Spaces expect port 7860
23
+ ENV PORT=7860
24
+ EXPOSE 7860
25
+
26
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -131,11 +131,32 @@ This project is configured for one-click deployment on Railway:
131
 
132
  The app will be live at your Railway-provided URL (e.g., `https://your-app.up.railway.app`)
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  ### Manual Deployment
135
 
136
  For other platforms, the project includes:
137
  - `Procfile`: `web: uvicorn app.main:app --host 0.0.0.0 --port $PORT`
138
  - `runtime.txt`: `python-3.11.9`
 
139
  - `requirements.txt`: All dependencies with versions
140
 
141
  ### Environment Variables
@@ -208,11 +229,8 @@ Tests cover:
208
 
209
  ## Environment Variables
210
 
211
- See `.env.example` for all required environment variables.
212
-
213
- ## Deployment
214
-
215
- This application is designed to deploy on Railway. Set the required environment variables in your Railway project settings.
216
 
217
  ## Tech Stack
218
 
 
131
 
132
  The app will be live at your Railway-provided URL (e.g., `https://your-app.up.railway.app`)
133
 
134
+ ### Hugging Face Spaces Deployment
135
+
136
+ Deploy on Hugging Face Spaces for free ML model hosting:
137
+
138
+ 1. **Create a new Space** on [Hugging Face](https://huggingface.co/spaces)
139
+ 2. **Select Docker** as the Space SDK
140
+ 3. **Upload your repository** files including the `Dockerfile`
141
+ 4. **Set environment variables** in Space settings:
142
+ - `SERPER_API_KEY`: Your Serper API key
143
+ 5. **Deploy automatically** - Spaces will build using the Dockerfile
144
+
145
+ The app will be live at your Space URL: `https://<your-space>.<your-username>.hf.space/`
146
+
147
+ **API Example for Spaces:**
148
+ ```bash
149
+ curl -X POST "https://<your-space>.<your-username>.hf.space/check" \
150
+ -H "Content-Type: application/json" \
151
+ -d '{"claim": "The Earth orbits the Sun."}'
152
+ ```
153
+
154
  ### Manual Deployment
155
 
156
  For other platforms, the project includes:
157
  - `Procfile`: `web: uvicorn app.main:app --host 0.0.0.0 --port $PORT`
158
  - `runtime.txt`: `python-3.11.9`
159
+ - `Dockerfile`: Docker container configuration for Spaces
160
  - `requirements.txt`: All dependencies with versions
161
 
162
  ### Environment Variables
 
229
 
230
  ## Environment Variables
231
 
232
+ - `SERPER_API_KEY`: **Required** - Get from [serper.dev](https://serper.dev)
233
+ - `DATABASE_URL`: Optional - SQLite database path (default: `./factcheck.db`)
 
 
 
234
 
235
  ## Tech Stack
236