Chapter 19: Deployment on Docker Containers (v0.19)

This commit is contained in:
Miguel Grinberg 2017-11-01 13:03:19 -07:00
parent f1b2b6f54c
commit c1943a1c4d
No known key found for this signature in database
3 changed files with 27 additions and 4 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:slim
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
RUN pip install gunicorn pymysql cryptography
COPY app app
COPY migrations migrations
COPY microblog.py config.py boot.sh ./
RUN chmod a+x boot.sh
ENV FLASK_APP microblog.py
RUN flask translate compile
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]

11
boot.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# this script is used to boot a Docker container
while true; do
flask db upgrade
if [[ "$?" == "0" ]]; then
break
fi
echo Deploy command failed, retrying in 5 secs...
sleep 5
done
exec gunicorn -b :5000 --access-logfile - --error-logfile - microblog:app

View File

@ -38,7 +38,3 @@ typing_extensions==4.8.0
urllib3==2.1.0
Werkzeug==3.0.1
WTForms==3.1.1
# requirements for Heroku
psycopg2-binary==2.9.9
gunicorn==21.2.0