Chapter 19: Deployment on Docker Containers (v0.19)
This commit is contained in:
parent
ae62fc9251
commit
53f4d49cb9
|
@ -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"]
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# this script is used to boot a Docker container
|
||||||
|
source venv/bin/activate
|
||||||
|
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
|
|
@ -39,5 +39,5 @@ Werkzeug==2.3.3
|
||||||
WTForms==3.0.1
|
WTForms==3.0.1
|
||||||
|
|
||||||
# requirements for Heroku
|
# requirements for Heroku
|
||||||
psycopg2-binary==2.9.6
|
#psycopg2-binary==2.9.6
|
||||||
gunicorn==20.1.0
|
#gunicorn==20.1.0
|
||||||
|
|
Loading…
Reference in New Issue