Kaballas commited on
Commit
b8dd4b1
·
1 Parent(s): ad96c1d
Files changed (2) hide show
  1. Dockerfile +2 -0
  2. entrypoint.sh +11 -5
Dockerfile CHANGED
@@ -37,4 +37,6 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
37
 
38
  COPY --chown=user . /app
39
 
 
 
40
  ENTRYPOINT ["/entrypoint.sh"]
 
37
 
38
  COPY --chown=user . /app
39
 
40
+
41
+
42
  ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh CHANGED
@@ -7,16 +7,22 @@ if [ ! -d /run/mysqld ]; then
7
  chown mysql:mysql /run/mysqld || true
8
  fi
9
 
10
- # Start MariaDB in the background
11
- service mariadb start
 
12
 
13
- # Wait for MariaDB to be ready
14
- until mysqladmin ping --silent; do
 
 
 
 
15
  echo 'Waiting for MariaDB to start...'
16
  sleep 1
17
  done
18
 
19
- echo 'MariaDB started.'
 
20
 
21
  # Start the Python app (foreground)
22
  exec uvicorn app:app --host 0.0.0.0 --port 7860
 
7
  chown mysql:mysql /run/mysqld || true
8
  fi
9
 
10
+ # Start MariaDB directly (better for containers)
11
+ mysqld_safe --datadir=/data/storage &
12
+ MYSQL_PID=$!
13
 
14
+ # Wait for MariaDB to be ready (with timeout)
15
+ for i in {1..30}; do
16
+ if mysqladmin ping --silent; then
17
+ echo 'MariaDB started.'
18
+ break
19
+ fi
20
  echo 'Waiting for MariaDB to start...'
21
  sleep 1
22
  done
23
 
24
+ # Trap signals for graceful shutdown
25
+ trap "echo 'Stopping MariaDB...'; kill $MYSQL_PID; wait $MYSQL_PID" SIGTERM SIGINT
26
 
27
  # Start the Python app (foreground)
28
  exec uvicorn app:app --host 0.0.0.0 --port 7860