From 030f548f162d218ddc5565124bf08d4767d5e86b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 14 Nov 2020 19:31:23 +0100 Subject: [PATCH] Integrate extensions creation in entry point Requires postgresql-client to be added to the image Closes #503 Signed-off-by: Thomas Citharel --- docker/production/Dockerfile | 2 +- docker/production/docker-entrypoint.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index d4c54e2f3..71b3e4e57 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -31,7 +31,7 @@ RUN mix phx.digest \ # Finally setup the app FROM alpine -RUN apk add --no-cache openssl ncurses-libs file +RUN apk add --no-cache openssl ncurses-libs file postgresql-client USER nobody EXPOSE 4000 diff --git a/docker/production/docker-entrypoint.sh b/docker/production/docker-entrypoint.sh index 9e118d45a..1d7a7a7f3 100755 --- a/docker/production/docker-entrypoint.sh +++ b/docker/production/docker-entrypoint.sh @@ -2,6 +2,14 @@ set -e +echo "-- Waiting for database..." +while ! pg_isready -U ${MOBILIZON_DATABASE_USERNAME} -d postgres://${MOBILIZON_DATABASE_HOST}:5432/${MOBILIZON_DATABASE_DBNAME} -t 1; do + sleep 1s +done + +PGPASSWORD=$MOBILIZON_DATABASE_PASSWORD psql -U $MOBILIZON_DATABASE_USERNAME -d $MOBILIZON_DATABASE_DBNAME -h $MOBILIZON_DATABASE_HOST -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;' +PGPASSWORD=$MOBILIZON_DATABASE_PASSWORD psql -U $MOBILIZON_DATABASE_USERNAME -d $MOBILIZON_DATABASE_DBNAME -h $MOBILIZON_DATABASE_HOST -c 'CREATE EXTENSION IF NOT EXISTS unaccent;' + echo "-- Running migrations..." /bin/mobilizon_ctl migrate