-
Notifications
You must be signed in to change notification settings - Fork 8
/
start_environment.sh
executable file
·41 lines (34 loc) · 1.28 KB
/
start_environment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
source variables
docker ps |grep "$DOCKER_DB_NAME"
run=$?
docker ps -a|grep "$DOCKER_DB_NAME"
exists=$?
if [ ${exists} -ne 0 ]
then
echo "###Base does not exist###"
else
echo "###Base does exist###"
docker stop $DOCKER_DB_NAME
docker rm -f $DOCKER_DB_NAME
fi
docker build --pull --rm -f Dockerfile-postgres -t $DOCKER_DB_NAME .
docker run --name $DOCKER_DB_NAME -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_USER=$DB_USER -e POSTGRES_DB=$DB_NAME -d $DOCKER_DB_NAME
until docker exec $DOCKER_DB_NAME /usr/lib/postgresql/10/bin/pg_isready; do sleep 2; done
docker rm -f $DOCKER_WEB_NAME
set -e
docker build --pull --rm -f Dockerfile-dev -t $DOCKER_WEB_NAME .
docker run --name $DOCKER_WEB_NAME --link $DOCKER_DB_NAME:$DOCKER_DB_NAME -d -v $(pwd):/var/www/ -v /dev/log:/dev/log -p 8009:80 $DOCKER_WEB_NAME
./run_composer.sh
DOCKER_DB_IP=$(docker inspect $DOCKER_DB_NAME|jq .[].NetworkSettings.IPAddress | tr -d '"')
DOCKER_WEB_IP=$(docker inspect $DOCKER_WEB_NAME|jq .[].NetworkSettings.IPAddress | tr -d '"')
echo
echo "Application available on http://localhost:8009"
echo " web IP = $DOCKER_WEB_IP"
echo " database IP = $DOCKER_DB_IP"
echo
echo export PGHOST=$DOCKER_DB_IP
echo export PGUSER=$DB_USER
echo export PGDATABASE=$DB_NAME
echo export PGPASSWORD=$DB_PASSWORD
echo