Avoid waiting for a postgresql which won't exist when this container is deployed

This commit is contained in:
R. Tyler Croy 2018-05-04 12:27:59 -07:00
parent 55e79bd9bf
commit a544668b53
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
3 changed files with 4 additions and 3 deletions

View File

@ -12,11 +12,12 @@ services:
image: jenkinsciinfra/evergreen-backend
build: ./services
environment:
- 'POSTGRES_PASSWORD=grassisevergreener'
- 'PGPASSWORD=grassisevergreener'
ports:
- '3030:3030'
depends_on:
- db
command: ['wait-for-postgres.sh', "db", "5432", "/usr/local/bin/npm", "run", "start"]
instance:
image: jenkins/evergreen

View File

@ -27,4 +27,4 @@ COPY wait-for-postgres.sh /wait-for-postgres.sh
RUN chmod a+x /wait-for-postgres.sh
RUN apk add --update-cache postgresql-client
CMD ["/wait-for-postgres.sh", "db", "5432", "/usr/local/bin/npm", "run", "start"]
CMD npm run start

View File

@ -15,7 +15,7 @@ cmd="$@"
maxAttempts=10
until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -p "$port" -U "postgres" -c '\q'; do
until psql -h "$host" -p "$port" -U "postgres" -c '\q'; do
maxAttempts=$(( $maxAttempts - 1 ))
if [[ $maxAttempts <= 0 ]]; then
>&2 echo "Maximum number of attempts reached: exitting"