diff --git a/BUGs b/BUGs index 15f5cb4..45c59b8 100644 --- a/BUGs +++ b/BUGs @@ -1,4 +1,4 @@ -#### BUGS (next-19) +#### BUGS (next-20) ### DB/back-end @@ -11,3 +11,4 @@ BUG-6: author,series, etc. do not have explicit ordering like sub-books... sort - add/remove authors, and after save they are ordered by author.id, not order of addition (prob. needs book_author_link to have an auth_num) #### SHOWSTOPPER: +BUG-19: show unrated gets all books, looks like ORM is not joining as I expected -- I wonder if it relates to that SAWarning about book id being written in the wrong spot? diff --git a/Dockerfile b/Dockerfile index ca0cbe8..46ec821 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,23 @@ FROM ubuntu:20.04 WORKDIR /code -RUN apt-get update && apt-get -y install python3-pip python3-psycopg2 libpq-dev gunicorn +USER root +ENV PJM_UID=500 +ENV PJM_GID=500 +RUN groupadd -g ${PJM_GID} mythtv && useradd -r -u ${PJM_UID} -g ${PJM_GID} mythtv +ENV TZ=Australia/Melbourne +RUN truncate -s0 /tmp/preseed.cfg && \ + (echo "tzdata tzdata/Areas select Australia" >> /tmp/preseed.cfg) && \ + (echo "tzdata tzdata/Zones/Australia select Melbourne" >> /tmp/preseed.cfg) && \ + debconf-set-selections /tmp/preseed.cfg && \ + rm -f /etc/timezone /etc/localtime && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ + apt-get install -y tzdata +## cleanup of files from setup +RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN apt-get update && apt-get -y install python3-pip python3-psycopg2 libpq-dev gunicorn python3-ldap COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt EXPOSE 443 COPY . . -CMD ["gunicorn", "--bind=0.0.0.0:443", "--workers=2","--threads=2", "--certfile", "/etc/letsencrypt/live/book.depaoli.id.au/fullchain.pem", "--keyfile", "/etc/letsencrypt/live/book.depaoli.id.au/privkey.pem","main:app"] +CMD gunicorn --bind=0.0.0.0:443 --workers=2 --threads=2 --certfile /etc/letsencrypt/live/book.depaoli.id.au/fullchain.pem --keyfile /etc/letsencrypt/live/book.depaoli.id.au/privkey.pem main:app --env FLASK_ENV="production" --error-logfile gunicorn.error.log --access-logfile gunicorn.log --capture-output diff --git a/main.py b/main.py index b521244..d9bb605 100644 --- a/main.py +++ b/main.py @@ -7,20 +7,16 @@ from wtforms import SubmitField, StringField, HiddenField, SelectField, IntegerF from flask_wtf import FlaskForm from status import st, Status import re -import socket +import os ####################################### Flask App globals ####################################### -DEV_HOST="mara" -hostname = socket.gethostname() -print( "Running on: {}".format( hostname) ) app = Flask(__name__) -### what is this value? I gather I should chagne it? # local DB conn string -if hostname == DEV_HOST: - DB_URL = 'postgresql+psycopg2://ddp:NWNlfa01@127.0.0.1:5432/library' -else: +if os.environ['FLASK_ENV'] == "production": DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@bookdb:5432/library' +else: + DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@127.0.0.1:55432/library' app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -750,7 +746,7 @@ def main_page(): return render_template("base.html", alert=st.GetAlert(), message=st.GetMessage()) if __name__ == "__main__": - if hostname == DEV_HOST: - app.run(host="0.0.0.0", debug=True) - else: + if os.environ['FLASK_ENV'] == "production": app.run(ssl_context=('/etc/letsencrypt/live/book.depaoli.id.au/cert.pem', '/etc/letsencrypt/live/book.depaoli.id.au/privkey.pem'), host="0.0.0.0", debug=False) + else: + app.run(host="0.0.0.0", debug=True) diff --git a/requirements.txt b/requirements.txt index 6ffd0a9..bd3f4c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ flask +flask_login +flask-ldap3-login sqlalchemy flask-sqlalchemy SQLAlchemy-serializer @@ -6,3 +8,7 @@ marshmallow-sqlalchemy flask-marshmallow flask-wtf flask-bootstrap +datetime +pytz +Werkzeug +flask-compress diff --git a/templates/base.html b/templates/base.html index ea6ec04..67b71c4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -36,7 +36,11 @@