Merge branch 'development' into 0.6.0--scanning_in-situ

This commit is contained in:
th3r00t
2020-09-02 18:35:47 -04:00
committed by GitHub
8 changed files with 38 additions and 17 deletions

1
.gitignore vendored
View File

@@ -135,4 +135,3 @@ pyshelf_nginx.conf
.env
tags
TAGS
config.json

View File

@@ -78,6 +78,8 @@ From the main directory
`pip install -r requirements.txt`
`./configure`
`cd src`
`python manage.py makemigrations`
@@ -90,10 +92,10 @@ From the main directory
`cd ..`
`./configure`
`./importBooks`
`uwsgi --ini uwsgi.ini`
Browse to the site as defined in your apache | nginx config
Running via the [Django](https://www.djangoproject.com/) test server might be possible, albeit not recomended.
@@ -113,7 +115,7 @@ services:
- "POSTGRES_USER=pyshelf"
- "POSTGRES_DB=pyshelf"
volumes:
- "pgdata:/var/lib/postgresql/data/"
- "db_data:/var/lib/postgresql/data/"
pyshelf:
image: "pyshelf/pyshelf"
@@ -125,7 +127,7 @@ services:
- db
volumes:
pgdata:
db_data:
```
You'll also need a `.env` file wich sets the `LOCAL_BOOK_DIR` variable, for example:
@@ -134,7 +136,7 @@ You'll also need a `.env` file wich sets the `LOCAL_BOOK_DIR` variable, for exam
LOCAL_BOOK_DIR=/home/someone/books
```
The Docker image is still new, so there could still be some issues and missing features. Feel free to create a bug-issue when you encounter a bug. Development of the Docker image is discussed in https://github.com/th3r00t/pyShelf/pull/53 . Currently the database needs to be [PostgreSQL](https://www.postgresql.org/) with the account details shown in the example `docker-compose.yml` .
The Docker image is still new, so there could still be some issues and missing features. Feel free to create a bug-issue when you encounter a bug. Development of the Docker image is discussed in https://github.com/th3r00t/pyShelf/pull/53 . Currently the database needs to be [PostgreSQL](https://www.postgresql.org/) with the account details shown in the example `docker-compose.yml`. It should become db agnostic in the future.
## In Progress

2
config.json Executable file → Normal file
View File

@@ -1 +1 @@
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "~/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "SECRET": ""}
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "~/books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "SECRET": "", "BUILD_MODE": "DEBUG"}

28
docker/Dockerfile vendored
View File

@@ -1,3 +1,14 @@
# This file is used to build the Dockerhub image. To host pyShelf yourself for
# production, please use the official pyShelf image on
# https://hub.docker.com/r/pyshelf/pyshelf
# Use the following commands to build and push the docker image to Dockerhub:
#
# docker build -t pyshelf/pyshelf -f ./docker/Dockerfile .
# docker login
# docker push pyshelf/pyshelf
FROM ubuntu
EXPOSE 8000
@@ -5,22 +16,27 @@ EXPOSE 8000
RUN apt-get update -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3 python3-dev python3-pip python3-venv nginx-full
COPY . /pyshelf
WORKDIR /pyshelf/
RUN python3 -m pip install -r requirements.txt
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y cron
RUN echo "* * * * * cd /pyshelf/ && python3 importBooks >> /var/log/cron.log 2>&1" > import_books_scheduler.cron && crontab import_books_scheduler.cron
COPY ./docker/pyshelf_nginx.conf /etc/nginx/sites-available/pyshelf_nginx.conf
RUN ln -s /etc/nginx/sites-available/pyshelf_nginx.conf /etc/nginx/sites-enabled/
COPY . /pyshelf
COPY ./docker/config.json /pyshelf/config.json
WORKDIR /pyshelf/
ENTRYPOINT cd src/ \
RUN python3 -m pip install -r requirements.txt
WORKDIR /pyshelf/
ENTRYPOINT cron start \
&& python3 configure \
&& cd src/ \
&& python3 manage.py makemigrations \
&& python3 manage.py makemigrations interface \
&& python3 manage.py migrate \
&& python3 manage.py migrate interface \
&& cd .. \
&& python3 configure \
&& python3 importBooks \
&& nginx -g "daemon on;" \
&& uwsgi --ini uwsgi.ini

1
docker/config.json vendored Normal file
View File

@@ -0,0 +1 @@
{"TITLE": "pyShelf E-Book Server", "VERSION": "Docker", "BOOKPATH": "/books", "DB_HOST": "db", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "SECRET": ""}

View File

@@ -1,11 +1,12 @@
version: "3.7"
# This file is used to test the docker image. To host pyShelf yourself for
# This file is used to test the Dockerhub image. To host pyShelf yourself for
# production, please use the official pyShelf image on
# https://hub.docker.com/r/pyshelf/pyshelf
# For development, use the following command in the root folder:
# `docker-compose -f .\docker\development.docker-compose.yml up --build`
#
# docker-compose -f ./docker/development.docker-compose.yml up --build
services:
db:

View File

@@ -37,7 +37,8 @@ class Config:
self.db_user = self._data["USER"]
self.db_pass = self._data["PASSWORD"]
self.SECRET = self._data["SECRET"]
self.debug_build_mode = (_data["BUILD_MODE"].casefold() == "debug")
def get_logger(self):
_logger = logger
_logger.add(pathlib.PurePath(self.root, 'data','{time}.log'),

View File

@@ -32,8 +32,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = CONFIG.SECRET
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = TEMPLATE_DEBUG = True
DEBUG = TEMPLATE_DEBUG = CONFIG.debug_build_mode
if DEBUG is True:
print("DEBUG build mode is ON")
from pudb.remote import set_trace
ALLOWED_HOSTS = CONFIG.allowed_hosts