Maksymilian Jankowski commited on
Commit
0b359eb
·
1 Parent(s): 6c106b0

deploy fix

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -4
Dockerfile CHANGED
@@ -4,7 +4,7 @@ FROM python:3.11-slim
4
  # Hugging Face passes the port to listen on via $PORT
5
  ENV PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1 \
7
- POETRY_VIRTUALENVS_CREATE=false
8
 
9
  WORKDIR /code
10
 
@@ -20,8 +20,30 @@ RUN apt-get update && \
20
  # ---- Copy project code ----------------------------------------------------
21
  COPY . .
22
 
23
- # ---- Supervisor configuration --------------------------------------------
24
- COPY deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  # ---- Start everything -----------------------------------------------------
27
- CMD ["/usr/bin/supervisord", "-n"]
 
 
 
 
 
 
4
  # Hugging Face passes the port to listen on via $PORT
5
  ENV PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1 \
7
+ PORT=7860
8
 
9
  WORKDIR /code
10
 
 
20
  # ---- Copy project code ----------------------------------------------------
21
  COPY . .
22
 
23
+ # ---- Create startup script ------------------------------------------------
24
+ RUN echo '#!/bin/bash\n\
25
+ set -e\n\
26
+ \n\
27
+ # Start Redis in background\n\
28
+ redis-server --daemonize yes --save "" --appendonly no\n\
29
+ \n\
30
+ # Start Celery worker in background\n\
31
+ celery -A utils.worker worker --pool=solo --loglevel=info --detach\n\
32
+ \n\
33
+ # Start FastAPI server in foreground\n\
34
+ exec uvicorn main:app --host 0.0.0.0 --port=${PORT:-7860}\n\
35
+ ' > /code/start.sh && chmod +x /code/start.sh
36
+
37
+ # ---- Fallback: Copy supervisor config if it exists -----------------------
38
+ RUN if [ -f deploy/supervisord.conf ]; then \
39
+ cp deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf; \
40
+ echo "Using supervisor"; \
41
+ fi
42
 
43
  # ---- Start everything -----------------------------------------------------
44
+ # Try supervisor first, fallback to simple script
45
+ CMD if [ -f /etc/supervisor/conf.d/supervisord.conf ]; then \
46
+ /usr/bin/supervisord -n; \
47
+ else \
48
+ /code/start.sh; \
49
+ fi