diff --git a/CalibreWebCompanion/CalibreWebCompanion/settings.py b/CalibreWebCompanion/CalibreWebCompanion/settings.py index caef3df..8648859 100644 --- a/CalibreWebCompanion/CalibreWebCompanion/settings.py +++ b/CalibreWebCompanion/CalibreWebCompanion/settings.py @@ -66,36 +66,36 @@ STATIC_ROOT = BASE_DIR + "/static/" -logfile = usersettings["LOGFILE"] -LOGGING = { - "version": 1, - "disable_existing_loggers": False, - "root": {"level": "INFO", "handlers": ["file"]}, - "handlers": { - "file": { - "level": "INFO", - "class": "logging.FileHandler", - "filename": usersettings["LOGFILE"], - "formatter": "app", - }, - }, - "loggers": { - "django": { - "handlers": ["file"], - "level": "INFO", - "propagate": True - }, - }, - "formatters": { - "app": { - "format": ( - u"%(asctime)s [%(levelname)-8s] " - "(%(module)s.%(funcName)s) %(message)s" - ), - "datefmt": "%Y-%m-%d %H:%M:%S", - }, - }, -} +# logfile = usersettings["LOGFILE"] +# LOGGING = { +# "version": 1, +# "disable_existing_loggers": False, +# "root": {"level": "INFO", "handlers": ["file"]}, +# "handlers": { +# "file": { +# "level": "INFO", +# "class": "logging.FileHandler", +# "filename": usersettings["LOGFILE"], +# "formatter": "app", +# }, +# }, +# "loggers": { +# "django": { +# "handlers": ["file"], +# "level": "INFO", +# "propagate": True +# }, +# }, +# "formatters": { +# "app": { +# "format": ( +# u"%(asctime)s [%(levelname)-8s] " +# "(%(module)s.%(funcName)s) %(message)s" +# ), +# "datefmt": "%Y-%m-%d %H:%M:%S", +# }, +# }, +# } ## ## ######################################################################## diff --git a/CalibreWebCompanion/gunicorn.conf.py b/CalibreWebCompanion/gunicorn.conf.py index ddee20c..5a3ca56 100644 --- a/CalibreWebCompanion/gunicorn.conf.py +++ b/CalibreWebCompanion/gunicorn.conf.py @@ -6,11 +6,10 @@ preload_app = True # By preloading an application you can save some RAM resource keepalive = 5 # daemon = True # Detaches the server from the controlling terminal and enters the background. disabled for now # logging - -errorlog = "/home/massiveatoms/Desktop/logs/gunicorn_error.log" +# errorlog = "/usr/src/app/data/logs/gunicorn_error.log" loglevel = "warning" -accesslog = "/home/massiveatoms/Desktop/logs/gunicorn_access.log" -# capture_output = True +# accesslog = "/usr/src/app/data/logs/gunicorn_access.log" +capture_output = True # debug settings which need to be commented out in prod # reload=True diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bfc991f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ + +## pull official base image +FROM python:3.8.3-alpine +EXPOSE 8080 +## set work directory +WORKDIR /usr/src/app +## install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt . +RUN pip install -r requirements.txt +RUN apk add nginx supervisor + +# do nginx stuff +RUN adduser -D -g 'www' www +RUN mkdir -p /run/nginx +COPY ./deployment/nginx.conf /etc/nginx/ + +## copy project +COPY ./CalibreWebCompanion ./CalibreWebCompanion + +## gunicorn borks started with supervisord +COPY ./supervisord.conf /etc/ +ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf + +# create some dirs +RUN mkdir /usr/src/app/logs + +# docker run --publish 8000:80 \ +# -v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \ +# -v '/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \ +# --name cw calibreweb:1.0.1 \ No newline at end of file diff --git a/Running b/Running new file mode 100644 index 0000000..e69de29 diff --git a/deployment/deploy.py b/deployment/deploy.py new file mode 100644 index 0000000..ac27398 --- /dev/null +++ b/deployment/deploy.py @@ -0,0 +1,4 @@ +from os import environ + + + diff --git a/deployment/nginx.conf b/deployment/nginx.conf index fda5f47..2eb8176 100644 --- a/deployment/nginx.conf +++ b/deployment/nginx.conf @@ -1,9 +1,9 @@ worker_processes 1; # user nobody nogroup; -user massiveatoms; +# user massiveatoms; # TEMP disabled # user nobody nobody; # for systems with 'nobody' as a group instead -error_log /home/massiveatoms/Desktop/logs/nginx.log warn; +# error_log /home/massiveatoms/Desktop/logs/nginx.log warn; # pid /var/run/nginx.pid; events { @@ -44,18 +44,18 @@ http { client_max_body_size 4G; # set the correct host(s) for your site - server_name localhost 192.168.1.4; # set this to the server url? or ip? we'll see MASSIVEATOMS + server_name localhost 0.0.0.0; # set this to the server url? or ip? we'll see MASSIVEATOMS keepalive_timeout 5; - # MASSIVEATOMS - location /download/ { - alias "/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/"; - # Never forget the fact that this little statement being root instead of alias caused us to lose more than a day troubleshooting - } + # # MASSIVEATOMS + # location /download/ { + # alias "/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/"; + # # Never forget the fact that this little statement being root instead of alias caused us to lose more than a day troubleshooting + # } location /static/ { - alias "/home/massiveatoms/Desktop/calibre-web-companion/CalibreWebCompanion/static/"; + alias "/usr/src/app/CalibreWebCompanion/static/"; # Never forget the fact that this little statement being root instead of alias caused us to lose more than a day troubleshooting } diff --git a/requirements.txt b/requirements.txt index b465ba0..eee8d92 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ django>=3.0.8 inotify>=0.2.10 +gunicorn>=20.0 # development -django-debug-toolbar>=2.2 -django-silk>=4.0 -locust>=1.1 -sqlalchemy>=1.3.15 -rich>=3.0 +# django-debug-toolbar>=2.2 +# django-silk>=4.0 +# locust>=1.1 +# sqlalchemy>=1.3.15 +# rich>=3.0 diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..ff6a699 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,26 @@ +[supervisord] +nodaemon=true +logfile=/tmp/supervisord.log +childlogdir=/tmp +pidfile = /tmp/supervisord.pid + +[program:gunicorn] +directory=/usr/src/app/CalibreWebCompanion +command=gunicorn CalibreWebCompanion.wsgi +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=false +startretries=0 +startsecs = 0 + +[program:nginx] +# user=www +command=nginx +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=false +startretries=0 \ No newline at end of file