diff --git a/Dockerfile b/Dockerfile index 9269745..bdfa8a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,11 @@ -FROM ubuntu:22.04 +FROM python WORKDIR /code -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 dist-upgrade && 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 -EXPOSE 5000 +ARG USERID +ARG GROUPID +RUN chown $USERID:$GROUPID /code +#RUN apt-get update && apt-get -y install python3-pip && apt-get -y dist-upgrade COPY . . +RUN pip3 install -r requirements.txt +EXPOSE 80 +EXPOSE 5000 CMD ["./wrapper.sh"] diff --git a/main.py b/main.py index 2199e04..c3af4da 100644 --- a/main.py +++ b/main.py @@ -829,7 +829,7 @@ def book(id): removing_series=[] for field in request.form: if 'removed-book_num' in field: - cnt=int(re.findall( '\d+', field )[0]) + cnt=int(re.findall( r'\d+', field )[0]) removing_series.append( { 'series_id' : request.form['removed-series_id-{}'.format(cnt)] } ) if book.IsParent(): @@ -865,7 +865,7 @@ def book(id): # reset rating on this/these series as the book has changed (and maybe the rating has changed) for field in request.form: if 'bsl-book_id-' in field and field != 'bsl-book_id-NUM': - cnt=int(re.findall( '\d+', field )[0]) + cnt=int(re.findall( r'\d+', field )[0]) s=Series.query.get(request.form['bsl-series_id-{}'.format(cnt)]) s.calcd_rating = CalcAvgRating(s.id) cnt=cnt+1 @@ -942,7 +942,7 @@ def stats(): @login_required def rem_books_from_loan(id): for field in request.form: - rem_id=int(re.findall( '\d+', field )[0]) + rem_id=int(re.findall( r'\d+', field )[0]) bll = Book_Loan_Link.query.filter(Book_Loan_Link.loan_id==id, Book_Loan_Link.book_id == rem_id ).one() db.session.delete(bll) db.session.commit() @@ -952,7 +952,7 @@ def rem_books_from_loan(id): @login_required def add_books_to_loan(id): for field in request.form: - add_id=int(re.findall( '\d+', field )[0]) + add_id=int(re.findall( r'\d+', field )[0]) bll = Book_Loan_Link( loan_id=id, book_id=add_id ) db.session.add(bll) db.session.commit() diff --git a/requirements.txt b/requirements.txt index 306e229..e43d687 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -psycopg2 Flask===2.3.3 Werkzeug==2.3.7 +psycopg2 +python3-ldap flask_login flask-ldap3-login sqlalchemy @@ -14,3 +15,4 @@ datetime pytz brotli flask-compress +gunicorn diff --git a/wrapper.sh b/wrapper.sh index 920f4cb..28b1fdd 100755 --- a/wrapper.sh +++ b/wrapper.sh @@ -1,11 +1,11 @@ #!/bin/bash if [ "$FLASK_ENV" == "production" ]; then - 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 --enable-stdio-inheritance + gunicorn --bind=0.0.0.0:80 --workers=2 --threads=2 main:app --env FLASK_ENV="production" --error-logfile /code/gunicorn.error.log --access-logfile /code/gunicorn.log --capture-output --enable-stdio-inheritance else cd /pybook_mapped_volume - gunicorn --bind=0.0.0.0:5000 --workers=1 --threads=1 main:app --env FLASK_ENV="$FLASK_ENV" --error-logfile gunicorn.error.log --access-logfile gunicorn.log --capture-output --enable-stdio-inheritance --reload + gunicorn --bind=0.0.0.0:5000 --workers=1 --threads=1 main:app --env FLASK_ENV="$FLASK_ENV" --error-logfile /code/gunicorn.error.log --access-logfile /code/gunicorn.log --capture-output --enable-stdio-inheritance --reload # just in case it fails - sleep 10000 + sleep 99999 fi