From 13252e056fc846170f18d5aeed92b13514ab9ad5 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Fri, 7 Feb 2025 22:35:54 +0100 Subject: [PATCH] MySQL > MariaDB --- Dockerfile | 10 +++++----- docker-start.sh | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12105dd..e4f841e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,17 +3,17 @@ FROM node:23.7.0-alpine # Install dependencies with versions RUN apk add --no-cache \ redis \ - mysql \ - mysql-client \ + mariadb \ + mariadb-client \ tmux # Create non-root user RUN addgroup -S appgroup && adduser -S appuser -G appgroup -# Setup MySQL +# Setup MariaDB RUN mkdir -p /run/mysqld && \ chown -R mysql:mysql /run/mysqld && \ - mysql_install_db --user=mysql --datadir=/var/lib/mysql + mariadb-install-db --user=mysql --datadir=/var/lib/mysql WORKDIR /usr/src/app COPY package*.json ./ @@ -29,6 +29,6 @@ USER appuser EXPOSE 80 6379 3306 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD mysqladmin ping -h localhost || exit 1 + CMD mariadb-admin ping -h localhost || exit 1 CMD ["./start.sh"] \ No newline at end of file diff --git a/docker-start.sh b/docker-start.sh index 045122a..fb7a966 100644 --- a/docker-start.sh +++ b/docker-start.sh @@ -10,7 +10,7 @@ cleanup() { echo "Cleaning up..." tmux kill-session -t $APP_NAME 2>/dev/null || true redis-cli shutdown || true - mysqladmin -u root shutdown || true + mariadb-admin -u root shutdown || true exit 0 } @@ -25,23 +25,23 @@ if ! redis-cli ping > /dev/null 2>&1; then exit 1 fi -# Start MySQL -echo "Starting MySQL..." -mysqld --user=mysql --datadir=/var/lib/mysql & +# Start MariaDB +echo "Starting MariaDB..." +mariadbd --user=mysql --datadir=/var/lib/mysql & -# Wait for MySQL with timeout -echo "Waiting for MySQL to be ready..." +# Wait for MariaDB with timeout +echo "Waiting for MariaDB to be ready..." COUNTER=0 -while ! mysqladmin ping -h localhost --silent; do +while ! mariadb-admin ping -h localhost --silent; do if [ $COUNTER -gt $MAX_MYSQL_WAIT ]; then - echo "MySQL failed to start within $MAX_MYSQL_WAIT seconds" + echo "MariaDB failed to start within $MAX_MYSQL_WAIT seconds" exit 1 fi echo "Still waiting..." sleep 2 COUNTER=$((COUNTER+2)) done -echo "MySQL is ready!" +echo "MariaDB is ready!" # Run migrations with error handling echo "Running database migrations..." @@ -61,8 +61,8 @@ while true; do echo "Redis died" exit 1 fi - if ! mysqladmin ping -h localhost --silent; then - echo "MySQL died" + if ! mariadb-admin ping -h localhost --silent; then + echo "MariaDB died" exit 1 fi if ! tmux has-session -t $APP_NAME 2>/dev/null; then