fixed Dockerfile - I only needed to expose 443, not sure what I was thinking mashing this web code with DB, anyway... also switched to using env var rather than hostname to pick up DEV/PROD, and now show that in base.html. Updated Dockerfile and requirements to prep for putting ldap/auth in, will need to copy some stuff from PA later. finally removed console debugs in book.html
This commit is contained in:
3
BUGs
3
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?
|
||||
|
||||
19
Dockerfile
19
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
|
||||
|
||||
18
main.py
18
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,7 +36,11 @@
|
||||
</div>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light justify-content-between">
|
||||
<a class="navbar-brand" href="/">Books DB</a>
|
||||
{% if config.ENV == "production" %}
|
||||
<a class="navbar-brand" href="/">Books DB</a>
|
||||
{% else %}
|
||||
<a class="navbar-brand bg-secondary text-white px-2 py-0" style="border-radius:4px" href="/">Books (DEV)</a>
|
||||
{% endif %}
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
@@ -93,7 +93,6 @@ function SeriesButPlus(num) {
|
||||
}
|
||||
|
||||
function AddBookToSeries() {
|
||||
console.log("add Book to series")
|
||||
|
||||
// Read the Number from that DIV's ID (i.e: 3 from "series-div-3") -- could
|
||||
// also be the filler (series-div-0), thats ok too
|
||||
@@ -139,7 +138,6 @@ console.log( "reset buttons on last_div is=" + last_div.prop('id') )
|
||||
}
|
||||
|
||||
function RemoveBookFromSeries(sid) {
|
||||
console.log("remove Book from Series: " + sid )
|
||||
$('#'+sid).remove()
|
||||
|
||||
var num = parseInt( sid.match(/\d+/g), 10 );
|
||||
|
||||
Reference in New Issue
Block a user