fix: Wait for postgres in worker service
This commit is contained in:
@@ -2,7 +2,7 @@ version: '3.9'
|
||||
services:
|
||||
main:
|
||||
build:
|
||||
context: ../images/wait-for-postgres
|
||||
context: ../images/main
|
||||
network: host
|
||||
ports:
|
||||
- '3000:3000'
|
||||
@@ -22,7 +22,7 @@ services:
|
||||
- automatisch_storage:/automatisch/storage
|
||||
worker:
|
||||
build:
|
||||
context: ../images/plain
|
||||
context: ../images/worker
|
||||
network: host
|
||||
depends_on:
|
||||
- main
|
||||
@@ -32,7 +32,6 @@ services:
|
||||
- POSTGRES_HOST=postgres
|
||||
- POSTGRES_DATABASE=automatisch
|
||||
- POSTGRES_USERNAME=automatisch_user
|
||||
command: automatisch start-worker --env-file /automatisch/storage/.env
|
||||
volumes:
|
||||
- automatisch_storage:/automatisch/storage
|
||||
postgres:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
set -e
|
||||
|
||||
until psql -h "$POSTGRES_HOST" -U "$POSTGRES_USERNAME" -d "$POSTGRES_HOST" -c '\q'; do
|
||||
>&2 echo "Postgres is unavailable - sleeping"
|
||||
>&2 echo "Waiting for Postgres to be ready..."
|
||||
sleep 1
|
||||
done
|
||||
|
@@ -1,5 +0,0 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:16
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN yarn global add @automatisch/cli@0.1.5
|
10
docker/images/worker/Dockerfile
Normal file
10
docker/images/worker/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:16
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN apt-get update && apt-get install -y postgresql-client
|
||||
|
||||
COPY ./wait-for-postgres.sh /automatisch/wait-for-postgres.sh
|
||||
|
||||
RUN yarn global add @automatisch/cli@0.1.5
|
||||
CMD sh /automatisch/wait-for-postgres.sh automatisch start-worker --env-file /automatisch/storage/.env
|
11
docker/images/worker/wait-for-postgres.sh
Normal file
11
docker/images/worker/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 "Waiting for Postgres to be ready..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up - executing command"
|
||||
exec "$@"
|
Reference in New Issue
Block a user