static file issue, otherwise working
This commit is contained in:
parent
d7a385fd45
commit
330a36556c
@ -66,36 +66,36 @@ STATIC_ROOT = BASE_DIR + "/static/"
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
logfile = usersettings["LOGFOLDER"] + "django.log"
|
# logfile = usersettings["LOGFOLDER"] + "django.log"
|
||||||
LOGGING = {
|
# LOGGING = {
|
||||||
"version": 1,
|
# "version": 1,
|
||||||
"disable_existing_loggers": False,
|
# "disable_existing_loggers": False,
|
||||||
"root": {"level": "INFO", "handlers": ["file"]},
|
# "root": {"level": "INFO", "handlers": ["file"]},
|
||||||
"handlers": {
|
# "handlers": {
|
||||||
"file": {
|
# "file": {
|
||||||
"level": "INFO",
|
# "level": "INFO",
|
||||||
"class": "logging.FileHandler",
|
# "class": "logging.FileHandler",
|
||||||
"filename": logfile,
|
# "filename": logfile,
|
||||||
"formatter": "app",
|
# "formatter": "app",
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
"loggers": {
|
# "loggers": {
|
||||||
"django": {
|
# "django": {
|
||||||
"handlers": ["file"],
|
# "handlers": ["file"],
|
||||||
"level": "INFO",
|
# "level": "INFO",
|
||||||
"propagate": True
|
# "propagate": True
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
"formatters": {
|
# "formatters": {
|
||||||
"app": {
|
# "app": {
|
||||||
"format": (
|
# "format": (
|
||||||
u"%(asctime)s [%(levelname)-8s] "
|
# u"%(asctime)s [%(levelname)-8s] "
|
||||||
"(%(module)s.%(funcName)s) %(message)s"
|
# "(%(module)s.%(funcName)s) %(message)s"
|
||||||
),
|
# ),
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
# "datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
}
|
# }
|
||||||
|
|
||||||
|
|
||||||
## ##
|
## ##
|
||||||
@ -140,6 +140,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
"library",
|
"library",
|
||||||
|
"django_extensions"
|
||||||
# "silk", # DEBUG/profilling purposes
|
# "silk", # DEBUG/profilling purposes
|
||||||
# 'debug_toolbar', # DEBUG purposes
|
# 'debug_toolbar', # DEBUG purposes
|
||||||
]
|
]
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import multiprocessing
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
|
|
||||||
bind = "127.0.0.1:8000"
|
|
||||||
workers = multiprocessing.cpu_count() * 2 + 1
|
|
||||||
preload_app = True # By preloading an application you can save some RAM resources as well as speed up server boot times
|
|
||||||
keepalive = 5
|
|
||||||
# daemon = True # Detaches the server from the controlling terminal and enters the background. disabled for now
|
|
||||||
# logging
|
|
||||||
|
|
||||||
with open("settings.json", "r") as jfile:
|
|
||||||
settings = json.load(jfile)
|
|
||||||
|
|
||||||
errorlog = settings["LOGFOLDER"] + "/gunicorn_error.log"
|
|
||||||
loglevel = "warning"
|
|
||||||
accesslog = settings["LOGFOLDER"] + "/gunicorn_access.log"
|
|
||||||
|
|
||||||
if not os.path.isdir("/usr/src/app/data/logs"):
|
|
||||||
os.mkdir("/usr/src/app/data/logs")
|
|
||||||
if not os.path.isfile(errorlog):
|
|
||||||
os.system('touch {}'.format(errorlog))
|
|
||||||
if not os.path.isfile(accesslog):
|
|
||||||
os.system('touch {}'.format(accesslog))
|
|
||||||
capture_output = True
|
|
||||||
|
|
||||||
# debug settings which need to be commented out in prod
|
|
||||||
# reload=True
|
|
||||||
# reload_engine = "inotify"
|
|
||||||
|
|
||||||
|
|
||||||
# I only went till the section https://docs.gunicorn.org/en/latest/settings.html#logging there are more settings
|
|
||||||
# some of them might be useful
|
|
@ -1,29 +1,24 @@
|
|||||||
|
|
||||||
## pull official base image
|
## pull official base image
|
||||||
FROM python:3.8.3-alpine
|
FROM nginx/unit:1.22.0-python3.9
|
||||||
EXPOSE 8080
|
EXPOSE 80
|
||||||
|
|
||||||
## set work directory
|
## set work directory
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
## install dependencies
|
## install dependencies
|
||||||
RUN pip install --upgrade pip
|
|
||||||
COPY ./requirements.txt .
|
COPY ./requirements.txt .
|
||||||
RUN pip install -r 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 project
|
||||||
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
||||||
copy ./deployment/startupscript.py ./
|
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
|
||||||
## gunicorn borks started with supervisord
|
# perms
|
||||||
COPY ./deployment/supervisord.conf /etc/
|
RUN chown -R unit:unit /usr/src/app
|
||||||
ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf
|
RUN chmod +x /docker-entrypoint.d/start.sh
|
||||||
|
|
||||||
|
|
||||||
# docker run --publish 8000:80 \
|
# docker run --publish 80:80 \
|
||||||
# -v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \
|
# -v '/home/MassiveAtoms/Desktop/logs:/usr/src/app/data' \
|
||||||
# -v '/run/media/massiveatoms/1AEEEA6EEEEA421D1/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
|
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
|
||||||
# --name cw calibreweb:1.0.1
|
# --name cw calibreweb:1.0
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
from os import environ
|
|
||||||
|
|
||||||
|
|
||||||
|
|
47
deployment/entrypoints/config.json
Normal file
47
deployment/entrypoints/config.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"listeners": {
|
||||||
|
"*:80": {
|
||||||
|
"pass": "routes"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"uri": "/static/*"
|
||||||
|
},
|
||||||
|
"action": {
|
||||||
|
"share": "/usr/src/app/CalibreWebCompanion/static"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"share": "/static/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"uri": "/download/*"
|
||||||
|
},
|
||||||
|
"action": {
|
||||||
|
"share": "/usr/src/app/calibredir/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"action": {
|
||||||
|
"pass": "applications/django"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"applications": {
|
||||||
|
"django": {
|
||||||
|
"type": "python 3",
|
||||||
|
"path": "/usr/src/app/CalibreWebCompanion/",
|
||||||
|
"module": "CalibreWebCompanion.wsgi",
|
||||||
|
"environment": {
|
||||||
|
"DJANGO_SETTINGS_MODULE": "CalibreWebCompanion.settings",
|
||||||
|
"DB_ENGINE": "django.db.backends.sqlite3"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
deployment/entrypoints/start.sh
Normal file
5
deployment/entrypoints/start.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
path=/usr/src/app/CalibreWebCompanion
|
||||||
|
chown -R unit:unit /usr/src/app
|
||||||
|
|
||||||
|
python "${path}/manage.py" makemigrations
|
||||||
|
python "${path}/manage.py" migrate
|
@ -8,9 +8,9 @@
|
|||||||
Here's an example of step 5
|
Here's an example of step 5
|
||||||
```
|
```
|
||||||
docker run --publish 80:80 \
|
docker run --publish 80:80 \
|
||||||
-v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \
|
-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' \
|
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/usr/src/app/calibredir' \
|
||||||
--name cw calibreweb:1.0.1
|
--name cw calibreweb:1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
your Calibre path/volume/whatever needs to be mounted at `/usr/src/app/calibredir`, and you need to mount a volume for the db and logs at `/usr/src/app/data`
|
your Calibre path/volume/whatever needs to be mounted at `/usr/src/app/calibredir`, and you need to mount a volume for the db and logs at `/usr/src/app/data`
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
worker_processes 1;
|
|
||||||
|
|
||||||
# user nobody nogroup;
|
|
||||||
user www www; # TEMP disabled
|
|
||||||
# user nobody nobody; # for systems with 'nobody' as a group instead
|
|
||||||
error_log /usr/src/app/data/logs/nginx.log warn;
|
|
||||||
# pid /var/run/nginx.pid;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024; # increase if you have lots of clients
|
|
||||||
accept_mutex off; # set to 'on' if nginx worker_processes > 1
|
|
||||||
use epoll; # to enable for Linux 2.6+ MASSIVEATOMS
|
|
||||||
# 'use kqueue;' to enable for FreeBSD, OSX
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include mime.types;
|
|
||||||
# fallback in case we can't determine a type
|
|
||||||
default_type application/octet-stream;
|
|
||||||
access_log /var/log/nginx/access.log combined;
|
|
||||||
sendfile on;
|
|
||||||
|
|
||||||
upstream app_server {
|
|
||||||
# fail_timeout=0 means we always retry an upstream even if it failed
|
|
||||||
# to return a good HTTP response
|
|
||||||
|
|
||||||
# for UNIX domain socket setups
|
|
||||||
# server unix:/tmp/gunicorn.sock fail_timeout=0;
|
|
||||||
|
|
||||||
# for a TCP configuration
|
|
||||||
server 127.0.0.1:8000 fail_timeout=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
# if no Host match, close the connection to prevent host spoofing
|
|
||||||
listen 80 default_server;
|
|
||||||
return 444;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80 deferred; # for Linux massiveatoms
|
|
||||||
# use 'listen 80 accept_filter=httpready;' for FreeBSD
|
|
||||||
# listen 80;
|
|
||||||
client_max_body_size 4G;
|
|
||||||
|
|
||||||
# set the correct host(s) for your site
|
|
||||||
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 "/usr/src/app/calibredir/";
|
|
||||||
# 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 "/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
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
# proxy_set_header Host $http_host;
|
|
||||||
# we don't want nginx trying to do something clever with
|
|
||||||
# redirects, we set the Host: header above already.
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_pass http://127.0.0.1:8000;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /500.html;
|
|
||||||
location = /500.html {
|
|
||||||
root /path/to/app/current/public;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
from os import system, chdir
|
|
||||||
|
|
||||||
|
|
||||||
# system("chown -R www:www /usr/src/app/calibredir")
|
|
||||||
# print("ownership of calibredir changed")
|
|
||||||
chdir("/usr/src/app/CalibreWebCompanion")
|
|
||||||
system("python ./manage.py makemigrations")
|
|
||||||
print("ran makemigrations")
|
|
||||||
system("python ./manage.py migrate")
|
|
||||||
print("migrate")
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
|||||||
[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
|
|
||||||
|
|
||||||
[program:startupscript]
|
|
||||||
directory=/usr/src/app
|
|
||||||
command=python ./startupscript.py
|
|
||||||
stdout_logfile=/dev/stdout
|
|
||||||
stdout_logfile_maxbytes=0
|
|
||||||
stderr_logfile=/dev/stderr
|
|
||||||
stderr_logfile_maxbytes=0
|
|
||||||
autorestart=false
|
|
||||||
startretries=0
|
|
@ -1,6 +1,7 @@
|
|||||||
django>=3.0.8
|
django>=3.0.8
|
||||||
inotify>=0.2.10
|
inotify>=0.2.10
|
||||||
gunicorn>=20.0
|
gunicorn>=20.0
|
||||||
|
django-extensions
|
||||||
# development
|
# development
|
||||||
# django-debug-toolbar>=2.2
|
# django-debug-toolbar>=2.2
|
||||||
# django-silk>=4.0
|
# django-silk>=4.0
|
||||||
|
Loading…
Reference in New Issue
Block a user