mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 09:51:59 +03:00
1cd9fc376d
https://github.com/hasura/graphql-engine-mono/pull/1848 GitOrigin-RevId: 2bd7c0a18448f042a1e35d21aaf42232acf48a46
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
### This file is not meant to be run directly, but to be sourced from
|
|
### the dev script. It defines all the functions required to run an
|
|
### MySQL docker container.
|
|
|
|
|
|
######################
|
|
# Configuration #
|
|
######################
|
|
|
|
if [ "$MODE" = "test" ]; then
|
|
MYSQL_PORT=33306
|
|
else
|
|
MYSQL_PORT=23306
|
|
fi
|
|
|
|
MYSQL_USER=root
|
|
MYSQL_PASSWORD=hasuraMySQL1
|
|
MYSQL_CONTAINER_NAME="hasura-dev-mysql-$MYSQL_PORT"
|
|
# space deliberately omitted between -u and -p params https://hub.docker.com/_/mysql
|
|
MYSQL_DOCKER="docker exec -it $MYSQL_CONTAINER_NAME mysql -u$MYSQL_USER -p$MYSQL_PASSWORD"
|
|
|
|
######################
|
|
# Functions #
|
|
######################
|
|
|
|
function mysql_launch_container(){
|
|
echo "Launching MySQL container: $MYSQL_CONTAINER_NAME"
|
|
docker run --name $MYSQL_CONTAINER_NAME \
|
|
-e MYSQL_ROOT_PASSWORD=$MYSQL_PASSWORD \
|
|
-e MYSQL_DATABASE=hasura \
|
|
-p 127.0.0.1:$MYSQL_PORT:3306 \
|
|
-d mysql:8.0 -h "127.0.0.1"
|
|
}
|
|
|
|
function mysql_wait {
|
|
echo -n "Waiting for mysql to come up"
|
|
until ( $MYSQL_DOCKER -e 'SELECT 1' ) &>/dev/null; do
|
|
echo -n '.' && sleep 0.2
|
|
done
|
|
echo " Ok"
|
|
}
|
|
|
|
function mysql_cleanup(){
|
|
echo "Removing $MYSQL_CONTAINER_NAME and its volumes in 5 seconds!"
|
|
echo " PRESS CTRL-C TO ABORT removal of all containers, or ENTER to clean up right away"
|
|
read -rt5 || true
|
|
docker stop "$MYSQL_CONTAINER_NAME"
|
|
docker rm -v "$MYSQL_CONTAINER_NAME"
|
|
}
|