Spaces:
Sleeping
Sleeping
Add Dockerfile and update port for Hugging Face deployment
Browse files- Dockerfile +27 -0
- main.py +1 -1
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Utiliser une image Python légère
|
| 2 |
+
FROM python:3.12-slim
|
| 3 |
+
|
| 4 |
+
# Définir le répertoire de travail
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Installer les dépendances système nécessaires (pour Kafka et SSL)
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
gcc \
|
| 10 |
+
python3-dev \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# Copier les fichiers de dépendances
|
| 14 |
+
COPY requirements.txt .
|
| 15 |
+
|
| 16 |
+
# Installer les dépendances Python
|
| 17 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
+
|
| 19 |
+
# Copier tout le projet dans le conteneur
|
| 20 |
+
COPY . .
|
| 21 |
+
|
| 22 |
+
# Hugging Face Spaces utilise le port 7860 par défaut
|
| 23 |
+
ENV PORT=7860
|
| 24 |
+
EXPOSE 7860
|
| 25 |
+
|
| 26 |
+
# Lancer l'application
|
| 27 |
+
CMD ["python", "main.py"]
|
main.py
CHANGED
|
@@ -228,5 +228,5 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
| 228 |
if websocket in ws_clients: ws_clients.remove(websocket)
|
| 229 |
|
| 230 |
if __name__ == "__main__":
|
| 231 |
-
port = int(os.environ.get("PORT",
|
| 232 |
uvicorn.run(app, host="0.0.0.0", port=port)
|
|
|
|
| 228 |
if websocket in ws_clients: ws_clients.remove(websocket)
|
| 229 |
|
| 230 |
if __name__ == "__main__":
|
| 231 |
+
port = int(os.environ.get("PORT", 7860))
|
| 232 |
uvicorn.run(app, host="0.0.0.0", port=port)
|