33
Browse files- Dockerfile +2 -0
- 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
|
11 |
-
|
|
|
12 |
|
13 |
-
# Wait for MariaDB to be ready
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
echo 'Waiting for MariaDB to start...'
|
16 |
sleep 1
|
17 |
done
|
18 |
|
19 |
-
|
|
|
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
|