From 6c39e8c5b79b23990e052991b28a55c9ba0db1d9 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Thu, 24 Aug 2017 18:56:11 -0700 Subject: [PATCH] Chapter 17: Docker Compose support (17f) --- .gitignore | 4 ++++ boot.sh | 11 ++++++++++- docker-compose.yml | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 37ce1aa50..1a86cb06b 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,7 @@ nosetests.xml # Virtual environment venv + +# Environment files +.env +.env-mysql diff --git a/boot.sh b/boot.sh index 897a03519..a6ca9f900 100755 --- a/boot.sh +++ b/boot.sh @@ -1,4 +1,13 @@ #!/bin/sh source venv/bin/activate -flask deploy + +while true; do + flask deploy + if [[ "$?" == "0" ]]; then + break + fi + echo Deploy command failed, retrying in 5 secs... + sleep 5 +done + exec gunicorn -b :5000 --access-logfile - --error-logfile - flasky:app diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..858fa3eda --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' +services: + flasky: + build: . + ports: + - "8000:5000" + env_file: .env + restart: always + links: + - mysql:dbserver + mysql: + image: "mysql/mysql-server:5.7" + env_file: .env-mysql + restart: always