Skip to content

Commit

Permalink
Healthcheck & Migration Logging
Browse files Browse the repository at this point in the history
Added healthcheck to Dockerfile & log statement for migration files

Signed-off-by: Bentley Hensel <[email protected]>
  • Loading branch information
TheBoatyMcBoatFace committed Sep 19, 2023
1 parent 50a585e commit 7f1bc7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7f1bc7f

Please sign in to comment.