chore: wait for postgres in docker compose
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
FROM node:16
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN apt-get update && apt-get install -y postgresql-client
|
||||
COPY ./docker/wait-for-postgres.sh /automatisch/wait-for-postgres.sh
|
||||
|
||||
# npm registry for dev purposes
|
||||
RUN npm config set fetch-retry-maxtimeout 5000
|
||||
RUN npm config set fetch-retry-mintimeout 3000
|
||||
@@ -15,4 +18,4 @@ RUN echo "APP_SECRET_KEY=$(openssl rand -base64 36)" >> /automatisch/storage/.en
|
||||
RUN yarn global add @automatisch/cli
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["automatisch", "start", "--env-file=/automatisch/storage/.env"]
|
||||
CMD sh /automatisch/wait-for-postgres.sh automatisch start --env-file=/automatisch/storage/.env
|
||||
|
11
docker/wait-for-postgres.sh
Normal file
11
docker/wait-for-postgres.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
until psql -h "$POSTGRES_HOST" -U "$POSTGRES_USERNAME" -d "$POSTGRES_HOST" -c '\q'; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - executing command"
|
||||
exec "$@"
|
Reference in New Issue
Block a user