Compare commits
No commits in common. "6e99404134c6798ed07aaed800641394b1c609c9" and "f34200901e9cd5085bb959b1000450e9405c7b10" have entirely different histories.
6e99404134
...
f34200901e
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,8 +3,7 @@ settings.json
|
|||||||
db.sqlite3
|
db.sqlite3
|
||||||
dummyusers.json
|
dummyusers.json
|
||||||
*.prof
|
*.prof
|
||||||
statictest.txt
|
|
||||||
./test.sh
|
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.vscode
|
.vscode
|
||||||
|
@ -23,10 +23,9 @@ with open(BASE_DIR + "/settings.json", "r") as userfile:
|
|||||||
CALIBRE_DIR = os.path.abspath(usersettings["CALIBRE_DIR"])
|
CALIBRE_DIR = os.path.abspath(usersettings["CALIBRE_DIR"])
|
||||||
SECRET_KEY = usersettings["SECRET_KEY"]
|
SECRET_KEY = usersettings["SECRET_KEY"]
|
||||||
ALLOWED_HOSTS = usersettings["ALLOWED_HOSTS"]
|
ALLOWED_HOSTS = usersettings["ALLOWED_HOSTS"]
|
||||||
|
INTERNAL_IPS = usersettings["INTERNAL_IPS"]
|
||||||
DEBUG = usersettings["DEBUG"]
|
DEBUG = usersettings["DEBUG"]
|
||||||
|
|
||||||
DOCKER = os.environ.get('AM_DOCKER_INSTANCE', False)
|
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
|
||||||
@ -65,41 +64,38 @@ STATIC_ROOT = BASE_DIR + "/static/"
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
# LOGGING
|
# LOGGING
|
||||||
|
|
||||||
# TODO: think about the issue for a bit. no write access to file on first run
|
|
||||||
# but startscript doesn't run to give access if it can't start django
|
|
||||||
# if not DOCKER:
|
# logfile = usersettings["LOGFOLDER"] + "django.log"
|
||||||
# logfile = "/app//data//django.log"
|
# LOGGING = {
|
||||||
# if not os.path.isfile(logfile):
|
# "version": 1,
|
||||||
# os.mknod(logfile)
|
# "disable_existing_loggers": False,
|
||||||
# LOGGING = {
|
# "root": {"level": "INFO", "handlers": ["file"]},
|
||||||
# "version": 1,
|
# "handlers": {
|
||||||
# "disable_existing_loggers": False,
|
# "file": {
|
||||||
# "root": {"level": "INFO", "handlers": ["file"]},
|
# "level": "INFO",
|
||||||
# "handlers": {
|
# "class": "logging.FileHandler",
|
||||||
# "file": {
|
# "filename": logfile,
|
||||||
# "level": "INFO",
|
# "formatter": "app",
|
||||||
# "class": "logging.FileHandler",
|
|
||||||
# "filename": logfile,
|
|
||||||
# "formatter": "app",
|
|
||||||
# },
|
|
||||||
# },
|
# },
|
||||||
# "loggers": {
|
# },
|
||||||
# "django": {
|
# "loggers": {
|
||||||
# "handlers": ["file"],
|
# "django": {
|
||||||
# "level": "INFO",
|
# "handlers": ["file"],
|
||||||
# "propagate": True
|
# "level": "INFO",
|
||||||
# },
|
# "propagate": True
|
||||||
# },
|
# },
|
||||||
# "formatters": {
|
# },
|
||||||
# "app": {
|
# "formatters": {
|
||||||
# "format": (
|
# "app": {
|
||||||
# u"%(asctime)s [%(levelname)-8s] "
|
# "format": (
|
||||||
# "(%(module)s.%(funcName)s) %(message)s"
|
# u"%(asctime)s [%(levelname)-8s] "
|
||||||
# ),
|
# "(%(module)s.%(funcName)s) %(message)s"
|
||||||
# "datefmt": "%Y-%m-%d %H:%M:%S",
|
# ),
|
||||||
# },
|
# "datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
# },
|
# },
|
||||||
# }
|
# },
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
## ##
|
## ##
|
||||||
@ -194,23 +190,19 @@ WSGI_APPLICATION = 'CalibreWebCompanion.wsgi.application'
|
|||||||
## DATBASE ##
|
## DATBASE ##
|
||||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||||
|
|
||||||
|
if usersettings["ISDOCKER"]:
|
||||||
if DOCKER:
|
defaultdb_path = "/usr/src/app/data/"
|
||||||
djangodb_path = "/app/CalibreWebCompanion"
|
|
||||||
calibredb_path = "/app/content/"
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
djangodb_path = BASE_DIR
|
defaultdb_path = BASE_DIR
|
||||||
calibredb_path = CALIBRE_DIR
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(djangodb_path, 'db.sqlite3'),
|
'NAME': os.path.join(defaultdb_path, 'db.sqlite3'),
|
||||||
},
|
},
|
||||||
'calibre': {
|
'calibre': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(calibredb_path, 'metadata.db'),
|
'NAME': os.path.join(CALIBRE_DIR, 'metadata.db'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="col s12 m7">
|
<div class="col s12 m7">
|
||||||
<div class="card z-depth-0 horizontal">
|
<div class="card z-depth-0 horizontal">
|
||||||
<div class="card-image">
|
<div class="card-image">
|
||||||
<a style="padding-top:15%" href=" /content/{{download}}"><img src=" /content/{{imgpath}}"
|
<a style="padding-top:15%" href=" /download/{{download}}"><img src=" /download/{{imgpath}}"
|
||||||
alt="download" srcset=""></a>
|
alt="download" srcset=""></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-stacked">
|
<div class="card-stacked">
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"CALIBRE_DIR": "/app/content",
|
"CALIBRE_DIR": "/usr/src/app/calibredir",
|
||||||
"LOGFOLDER" : "/usr/src/app/data/logs/",
|
|
||||||
"SECRET_KEY": "u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+",
|
"SECRET_KEY": "u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+",
|
||||||
"ALLOWED_HOSTS": [
|
"ALLOWED_HOSTS": [
|
||||||
"*"
|
"127.0.0.1"
|
||||||
],
|
],
|
||||||
"INTERNAL_IPS": [
|
"INTERNAL_IPS": [
|
||||||
"127.0.0.1", "localhost"
|
"127.0.0.1"
|
||||||
],
|
],
|
||||||
"DEBUG" : false
|
"DEBUG" : true,
|
||||||
|
"LOGFOLDER" : "/usr/src/app/data/logs/",
|
||||||
|
"ISDOCKER" : true
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,22 +2,23 @@
|
|||||||
## pull official base image
|
## pull official base image
|
||||||
FROM nginx/unit:1.22.0-python3.9
|
FROM nginx/unit:1.22.0-python3.9
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENV AM_DOCKER_INSTANCE Yes
|
|
||||||
## set work directory
|
## set work directory
|
||||||
WORKDIR /app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
## install dependencies
|
## install dependencies
|
||||||
COPY ./requirements.txt .
|
COPY ./requirements.txt .
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
## copy project
|
## copy project
|
||||||
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
||||||
|
|
||||||
# perms
|
|
||||||
RUN chown -R unit:unit /app
|
|
||||||
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
|
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
|
||||||
|
# perms
|
||||||
|
RUN chown -R unit:unit /usr/src/app
|
||||||
RUN chmod +x /docker-entrypoint.d/start.sh
|
RUN chmod +x /docker-entrypoint.d/start.sh
|
||||||
|
|
||||||
|
|
||||||
# docker run --publish 80:80 \
|
# docker run --publish 80:80 \
|
||||||
# -v '/home/MassiveAtoms/Desktop/logs:/app/data' \
|
# -v '/home/MassiveAtoms/Desktop/logs:/usr/src/app/data' \
|
||||||
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/app/calibredir' \
|
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
|
||||||
# --name cw calibreweb:1.0
|
# --name cw calibreweb:1.0
|
||||||
|
@ -6,30 +6,14 @@
|
|||||||
},
|
},
|
||||||
"routes": [
|
"routes": [
|
||||||
{
|
{
|
||||||
"match": {
|
"match": {"uri": "/static/*"},
|
||||||
"uri": [
|
"action": {"share": "/usr/src/app/CalibreWebCompanion/static"}
|
||||||
"/content/*",
|
|
||||||
"!~\\.db"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"share": "/app/"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"match": {
|
"match": {"uri": "/download/*"},
|
||||||
"uri": "/static/*"
|
"action": {"share": "/usr/src/app/calibredir"}
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"share": "/app/CalibreWebCompanion/"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"match": {
|
|
||||||
"uri": [
|
|
||||||
"!~\\.db", "*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"action": {
|
"action": {
|
||||||
"pass": "applications/django"
|
"pass": "applications/django"
|
||||||
}
|
}
|
||||||
@ -38,16 +22,12 @@
|
|||||||
"applications": {
|
"applications": {
|
||||||
"django": {
|
"django": {
|
||||||
"type": "python 3",
|
"type": "python 3",
|
||||||
"path": "/app/CalibreWebCompanion/",
|
"path": "/usr/src/app/CalibreWebCompanion/",
|
||||||
"module": "CalibreWebCompanion.wsgi",
|
"module": "CalibreWebCompanion.wsgi",
|
||||||
"environment": {
|
"environment": {
|
||||||
"DJANGO_SETTINGS_MODULE": "CalibreWebCompanion.settings",
|
"DJANGO_SETTINGS_MODULE": "CalibreWebCompanion.settings",
|
||||||
"DB_ENGINE": "django.db.backends.sqlite3"
|
"DB_ENGINE": "django.db.backends.sqlite3"
|
||||||
},
|
|
||||||
"processes" : {
|
|
||||||
"max": 25,
|
|
||||||
"spare": 1,
|
|
||||||
"idle_timeout": 20
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,5 @@
|
|||||||
CAL_DIR="/app/content/"
|
path=/usr/src/app/CalibreWebCompanion
|
||||||
DATA_DIR="/app/data/"
|
chown -R unit:unit /usr/src/app
|
||||||
CWC_PATH="/app/CalibreWebCompanion"
|
|
||||||
if [ ! -d "$CAL_DIR" ]; then
|
|
||||||
echo "Calibre Library not mounted at the correct location."
|
|
||||||
echo "Mount it at /app/content/"
|
|
||||||
echo "Exiting..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$DATA_DIR" ]; then
|
python "${path}/manage.py" makemigrations
|
||||||
echo "A data directory not mounted at the correct location, exiting"
|
python "${path}/manage.py" migrate
|
||||||
echo "This is used to store the database and logs"
|
|
||||||
echo "mount something at /app/data/"
|
|
||||||
echo "exiting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp -R -u -p "/app/CalibreWebCompanion/db.sqlite3" "/app/data/"
|
|
||||||
ls -l /app
|
|
||||||
python "${CWC_PATH}/manage.py" makemigrations
|
|
||||||
python "${CWC_PATH}/manage.py" migrate
|
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
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:/app/data' \
|
-v '/home/MassiveAtoms/Desktop/logs:/usr/src/app/data' \
|
||||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/app/calibredir' \
|
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/usr/src/app/calibredir' \
|
||||||
--name cw calibreweb:1.0
|
--name cw calibreweb:1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
your Calibre path/volume/whatever needs to be mounted at `/app/calibredir`, and you need to mount a volume for the db and logs at `/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`
|
||||||
|
|
||||||
Issues with it at the moment:
|
Issues with it at the moment:
|
||||||
1. we still need to do something to create a random secret key. Atm, this would still
|
1. we still need to do something to create a random secret key. Atm, this would still
|
||||||
|
17
test.sh
17
test.sh
@ -1,17 +0,0 @@
|
|||||||
docker build --tag calibreweb:1.0 . -f ./deployment/Dockerfile
|
|
||||||
docker stop cw
|
|
||||||
docker rm cw
|
|
||||||
docker run --publish 80:80 \
|
|
||||||
-v '/home/MassiveAtoms/Desktop/logs:/app/data' \
|
|
||||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/app/content' \
|
|
||||||
--name cw calibreweb:1.0
|
|
||||||
sleep 8
|
|
||||||
echo "download/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/download/statictest.txt
|
|
||||||
echo " "
|
|
||||||
echo "/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/statictest.txt
|
|
||||||
echo " "
|
|
||||||
echo "/static/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/static/statictest.txt
|
|
||||||
echo " "
|
|
Loading…
Reference in New Issue
Block a user