Wait-for is a binary used to wait for a resource (like a database or a message broker) to be available. It supports PostgreSQL, MySQL, MongoDB databases and RabbitMQ message broker.
Here is an example of wait-for installation in a Dockerfile:
ENV WAIT_FOR_VERSION=v0.0.4
RUN wget "https://github.com/arcanjoaq/wait-for/releases/download/${WAIT_FOR_VERSION}/wait-for" && chmod u+x wait-for
Basically, the option --type determines the target resource. Here are some examples of wait-for:
./wait-for --type mysql \
--host localhost \
--port 3306 \
--user root \
--password mysql \
--name mysql \
--maxAttempts 100
./wait-for --type postgres \
--host localhost \
--port 5432 \
--user test \
--password test \
--name test \
--maxAttempts 100
./wait-for --type mongodb \
--host localhost \
--port 27017 \
--user test \
--password test \
--name test \
--maxAttempts 100
./wait-for --type rabbitmq \
--host localhost \
--port 5672 \
--user test \
--password test \
--name '/' \
--maxAttempts 100
--type: Set resource type.
--host: Set target host. The default value is "localhost".
--port: Set resource port. The default value depends on resource type.
--user: Set resource user.
--password: Set resource password.
--name: Se resource name. It is database name or virtual host name.
--seconds: Set number of seconds to wait for a resource. The default value is "10".
--maxAttempts: Set max attempts quantity. The default value is "3".
make lint
make build