Using docker-compose-wait without a Dockerfile?
jflambert opened this issue · comments
I have a simple use case where I just want to load postgresql (timescaledb) and then Hasura. Problem is that I initialize postgresql with lots of data, after which hasura can set up complex metadata/migrations. Each process can take up to a minute.
Then on top of that I have my application, which can be modified to use docker-compose-wait to wait on Hasura, yes. But first I want Hasura to wait on Postgres. Basically I want to use docker-compose-wait for "third-party images". Is this possible?
Take into example the following docker-compose.yaml
file. I would like to tell graphql-engine
to wait for port 5432 to be available (instead of depends_on
), but I "can't" change timescaledb because it's not "mine". However I'm a bit of a novice, so I'm most likely missing a very obvious point here.
Please enlighten me! Great project!
version: '3.6'
services:
postgres:
image: timescale/timescaledb:latest-pg12
ports:
- "5432:5432"
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: testdb
POSTGRES_PASSWORD: postgrespassword
TIMESCALEDB_TELEMETRY: "off"
graphql-engine:
image: hasura/graphql-engine:v1.3.0-beta.3.cli-migrations-v2
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
volumes:
- ./hasura/migrations:/hasura-migrations
- ./hasura/metadata:/hasura-metadata
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/testdb
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_ENABLE_TELEMETRY: "false"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
volumes:
db_data:
Hi @jflambert ,
you can find some info in the home page doc:
If you want to use the script directly in docker-compose.yml instead of the Dockerfile, please note that the command: configuration option is limited to a single command so you should wrap in a sh call. For example:
command: sh -c "/wait && /MySuperApp.sh"
Anyway, the wait
executable must be in the docker image so it would not work out of the box for the hasura/graphql-engine
image.
What you can do is, instead, creating a new image from hasura/graphql-engine
; for example, something like:
FROM hasura/graphql-engine:v1.3.0-beta.3.cli-migrations-v2
## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait
CMD /wait && /start_of_the_hasura_image.sh