update to use user: 2000:2000 / ARGS in build, and use the python image instead of a full ubuntu image. Also use r to escape regex str
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,24 +1,11 @@
|
|||||||
FROM ubuntu:22.04
|
FROM python
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
USER root
|
ARG USERID
|
||||||
ENV PJM_UID=500
|
ARG GROUPID
|
||||||
ENV PJM_GID=500
|
RUN chown $USERID:$GROUPID /code
|
||||||
RUN groupadd -g ${PJM_GID} mythtv && useradd -r -u ${PJM_UID} -g ${PJM_GID} mythtv
|
#RUN apt-get update && apt-get -y install python3-pip && apt-get -y dist-upgrade
|
||||||
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
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
EXPOSE 80
|
||||||
|
EXPOSE 5000
|
||||||
CMD ["./wrapper.sh"]
|
CMD ["./wrapper.sh"]
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -829,7 +829,7 @@ def book(id):
|
|||||||
removing_series=[]
|
removing_series=[]
|
||||||
for field in request.form:
|
for field in request.form:
|
||||||
if 'removed-book_num' in field:
|
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)] } )
|
removing_series.append( { 'series_id' : request.form['removed-series_id-{}'.format(cnt)] } )
|
||||||
|
|
||||||
if book.IsParent():
|
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)
|
# reset rating on this/these series as the book has changed (and maybe the rating has changed)
|
||||||
for field in request.form:
|
for field in request.form:
|
||||||
if 'bsl-book_id-' in field and field != 'bsl-book_id-NUM':
|
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=Series.query.get(request.form['bsl-series_id-{}'.format(cnt)])
|
||||||
s.calcd_rating = CalcAvgRating(s.id)
|
s.calcd_rating = CalcAvgRating(s.id)
|
||||||
cnt=cnt+1
|
cnt=cnt+1
|
||||||
@@ -942,7 +942,7 @@ def stats():
|
|||||||
@login_required
|
@login_required
|
||||||
def rem_books_from_loan(id):
|
def rem_books_from_loan(id):
|
||||||
for field in request.form:
|
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()
|
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.delete(bll)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@@ -952,7 +952,7 @@ def rem_books_from_loan(id):
|
|||||||
@login_required
|
@login_required
|
||||||
def add_books_to_loan(id):
|
def add_books_to_loan(id):
|
||||||
for field in request.form:
|
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 )
|
bll = Book_Loan_Link( loan_id=id, book_id=add_id )
|
||||||
db.session.add(bll)
|
db.session.add(bll)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
psycopg2
|
|
||||||
Flask===2.3.3
|
Flask===2.3.3
|
||||||
Werkzeug==2.3.7
|
Werkzeug==2.3.7
|
||||||
|
psycopg2
|
||||||
|
python3-ldap
|
||||||
flask_login
|
flask_login
|
||||||
flask-ldap3-login
|
flask-ldap3-login
|
||||||
sqlalchemy
|
sqlalchemy
|
||||||
@@ -14,3 +15,4 @@ datetime
|
|||||||
pytz
|
pytz
|
||||||
brotli
|
brotli
|
||||||
flask-compress
|
flask-compress
|
||||||
|
gunicorn
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$FLASK_ENV" == "production" ]; then
|
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
|
else
|
||||||
cd /pybook_mapped_volume
|
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
|
# just in case it fails
|
||||||
sleep 10000
|
sleep 99999
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user