From 2afeec85daf8162154647a28c714a7caca818649 Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Fri, 26 Dec 2025 16:48:43 -0700 Subject: [PATCH] Update entrypoint.sh to support PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Auto-detect database type from DATABASE_URL - Use pg_isready for PostgreSQL health check - Use mysqladmin ping for MariaDB/MySQL - Default to postgres if not specified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- docker/entrypoint.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 3552646..5fad5ab 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,24 +12,37 @@ echo -e "${GREEN}KeepItGoing Docker Entrypoint${NC}" echo -e "${GREEN}========================================${NC}" # Extract database host from DATABASE_URL or use DB_HOST env var -DB_HOST=${DB_HOST:-mariadb} +DB_HOST=${DB_HOST:-postgres} -# Wait for MariaDB to be ready -echo -e "${YELLOW}Waiting for MariaDB at ${DB_HOST}...${NC}" +# Detect database type from DATABASE_URL +if echo "$DATABASE_URL" | grep -q "mysql\|mariadb"; then + DB_TYPE="mysql" + DB_CHECK_CMD="mysqladmin ping -h${DB_HOST} --silent" +elif echo "$DATABASE_URL" | grep -q "postgres"; then + DB_TYPE="postgres" + DB_CHECK_CMD="pg_isready -h ${DB_HOST} -U ${DB_USER:-keepitgoing}" +else + # Default to postgres + DB_TYPE="postgres" + DB_CHECK_CMD="pg_isready -h ${DB_HOST} -U ${DB_USER:-keepitgoing}" +fi + +# Wait for database to be ready +echo -e "${YELLOW}Waiting for database at ${DB_HOST}...${NC}" max_attempts=30 attempt=0 -while ! mysqladmin ping -h"${DB_HOST}" --silent 2>/dev/null; do +while ! eval $DB_CHECK_CMD 2>/dev/null; do attempt=$((attempt + 1)) if [ $attempt -eq $max_attempts ]; then - echo -e "${RED}ERROR: MariaDB did not become available in time${NC}" + echo -e "${RED}ERROR: Database did not become available in time${NC}" exit 1 fi - echo "Waiting for MariaDB... ($attempt/$max_attempts)" + echo "Waiting for database... ($attempt/$max_attempts)" sleep 2 done -echo -e "${GREEN}✓ MariaDB is ready!${NC}" +echo -e "${GREEN}✓ Database is ready!${NC}" # Function to run migrations run_migrations() {