AIVLAD commited on
Commit
c83092b
·
1 Parent(s): 13c85a8

fix: improve container startup reliability and logging

Browse files

- Increase healthcheck start period from 40s to 120s for slow migrations
- Simplify healthcheck to check nginx root instead of Django API
- Add verbose logging to supervisord and start-django.sh
- Increment CACHEBUST to 3

This gives Django more time to run migrations and provides better debugging visibility.

Files changed (3) hide show
  1. Dockerfile +4 -4
  2. start-django.sh +7 -1
  3. supervisord.conf +2 -1
Dockerfile CHANGED
@@ -19,7 +19,7 @@ RUN npm run build
19
  FROM nginx:alpine
20
 
21
  # Cache buster to force rebuild on HuggingFace (increment when needed)
22
- ARG CACHEBUST=2
23
 
24
  # Install Python, pip, supervisor, and curl for healthcheck
25
  RUN apk add --no-cache \
@@ -61,8 +61,8 @@ WORKDIR /app
61
 
62
  EXPOSE 7860
63
 
64
- # Healthcheck to verify services are running
65
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
66
- CMD curl -f http://localhost:7860/api/ || exit 1
67
 
68
  CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
 
19
  FROM nginx:alpine
20
 
21
  # Cache buster to force rebuild on HuggingFace (increment when needed)
22
+ ARG CACHEBUST=3
23
 
24
  # Install Python, pip, supervisor, and curl for healthcheck
25
  RUN apk add --no-cache \
 
61
 
62
  EXPOSE 7860
63
 
64
+ # Healthcheck to verify nginx is responding (simpler than checking Django API)
65
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
66
+ CMD curl -f http://localhost:7860/ || exit 1
67
 
68
  CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
start-django.sh CHANGED
@@ -1,6 +1,10 @@
1
  #!/bin/sh
2
  set -e
3
 
 
 
 
 
4
  cd /app
5
 
6
  # Verify /tmp is writable for SQLite database
@@ -9,9 +13,11 @@ touch /tmp/.write-test && rm /tmp/.write-test || {
9
  echo "ERROR: /tmp is not writable"
10
  exit 1
11
  }
 
12
 
13
  echo "Running database migrations..."
14
  python3 manage.py migrate --noinput
 
15
 
16
- echo "Starting Gunicorn..."
17
  exec gunicorn config.wsgi:application --bind 127.0.0.1:8000 --workers 2 --access-logfile - --error-logfile -
 
1
  #!/bin/sh
2
  set -e
3
 
4
+ echo "=== Django Startup ==="
5
+ echo "Working directory: $(pwd)"
6
+ echo "Python version: $(python3 --version)"
7
+
8
  cd /app
9
 
10
  # Verify /tmp is writable for SQLite database
 
13
  echo "ERROR: /tmp is not writable"
14
  exit 1
15
  }
16
+ echo "/tmp is writable"
17
 
18
  echo "Running database migrations..."
19
  python3 manage.py migrate --noinput
20
+ echo "Migrations complete"
21
 
22
+ echo "Starting Gunicorn on 127.0.0.1:8000..."
23
  exec gunicorn config.wsgi:application --bind 127.0.0.1:8000 --workers 2 --access-logfile - --error-logfile -
supervisord.conf CHANGED
@@ -1,6 +1,7 @@
1
  [supervisord]
2
  nodaemon=true
3
- logfile=/dev/null
 
4
  logfile_maxbytes=0
5
  pidfile=/var/run/supervisord.pid
6
 
 
1
  [supervisord]
2
  nodaemon=true
3
+ loglevel=info
4
+ logfile=/dev/stdout
5
  logfile_maxbytes=0
6
  pidfile=/var/run/supervisord.pid
7