GrupoTP-37/docker/start.sh
2023-11-07 19:34:50 +00:00

40 lines
913 B
Bash
Executable file

#!/usr/bin/bash
set -x
# Build image
if [ "$(docker network list | grep laravel_net)" == "" ]
then
docker network create laravel_net
fi
if [ "$(docker container list | grep laraveldb)" == "" ]
then
docker run --name laraveldb --net laravel_net -p 3306:3306 -d \
-e MYSQL_USER=myuser \
-e MYSQL_PASSWORD=password \
-e MYSQL_DATABASE=laravel \
-e MYSQL_ALLOW_EMPTY_PASSWORD=true \
mysql:latest
fi
# only build image if it doesn't exist
if [ "$(docker image list | grep laravelio)" == "" ]
then
docker build . -t laravelio
fi
sleep 5
docker run --name laravel --net laravel_net -p 80:8000 -d \
-e DB_CONNECTION=mysql \
-e DB_HOST=laraveldb \
-e DB_DATABASE=laravel \
-e DB_USERNAME=myuser \
-e DB_PASSWORD=password \
laravelio
sleep 5
curl --write-out '%{http_code}' --silent http://localhost:80/ --output output.html