From 7f1bc7f2a4b52cdb0dbd54e8d0cf4ed4b5b46108 Mon Sep 17 00:00:00 2001 From: Bentley Hensel Date: Tue, 19 Sep 2023 13:49:52 -0400 Subject: [PATCH] Healthcheck & Migration Logging Added healthcheck to Dockerfile & log statement for migration files Signed-off-by: Bentley Hensel --- Dockerfile | 5 +++++ migrate.sh | 1 + 2 files changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 822d99c..d919967 100644 --- a/Dockerfile +++ b/Dockerfile @@ -199,6 +199,8 @@ RUN chmod +x /docker-entrypoint-initdb.d/migrate.sh # Create migrations directory and copy files COPY /migrations /docker-entrypoint-initdb.d/migrations/ + + # RUN mkdir -p /usr/local/bin/migrations/ # COPY ./migrations/* /usr/local/bin/migrations/ @@ -212,6 +214,9 @@ ADD --chmod=0755 \ /usr/local/bin/ ENTRYPOINT ["docker-entrypoint.sh"] +HEALTHCHECK --interval=2s --timeout=2s --retries=10 CMD pg_isready -U healthchecker -h localhost -d gova11y + + # We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL # calls "Fast Shutdown mode" wherein new connections are disallowed and any diff --git a/migrate.sh b/migrate.sh index 549fb3a..4a701f6 100644 --- a/migrate.sh +++ b/migrate.sh @@ -53,6 +53,7 @@ for migration in $(ls $MIGRATIONS_DIR | sort); do # Check if the migration has been applied already applied=$(psql -tAc "SELECT 1 FROM toolbox.migrations WHERE migration_name='$migration'") if [[ "$applied" != "1" ]]; then + echo "Processing migration file: $migration" psql -a -f "$MIGRATIONS_DIR/$migration" if [ $? -ne 0 ]; then echo "Error applying migration $migration"