diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..972b18b --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/boot.sh b/boot.sh new file mode 100755 index 0000000..2f0992d --- /dev/null +++ b/boot.sh @@ -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 diff --git a/requirements.txt b/requirements.txt index 3ebea53..748314d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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