Merge pull request #51 from th3r00t/0.5.0--docker

Merge docker branch into newui
This commit is contained in:
th3r00t
2020-07-26 21:59:14 -04:00
committed by GitHub
6 changed files with 87 additions and 1 deletions

28
README.md vendored
View File

@@ -114,6 +114,34 @@ All configuration is now handled by the installer.
Running via the Django test server might be possible, albeit not recomended. Running via the Django test server might be possible, albeit not recomended.
## Docker
Installation for Docker is handled by docker-compose
It will spin up two containers: one postgres, one for the Django application
Edit [docker/.env](docker/.env)
`docker-compose -f docker/docker-compose.yml --env-file=docker/.env up -d`
`docker exec -it -d docker_pyshelf_1 python3 manage.py migrate`
`docker exec -it -d docker_pyshelf_1 python3 manage.py runserver 0.0.0.0:8000`
IMPORT BOOKS
Once the .epub files are in the directory specified in [docker/.env](docker/.env)
`docker exec -it docker_pyshelf_1 /bin/bash`
`cd /usr/src/app/ && python3 importBooks`
### Docker Future Enhancements
- [ ] Change method of importing books ssibly cron or using the Django code
- [ ] Look into having the migration work without having to manually execute
### In Progress ### In Progress
#### Organizational tools. #### Organizational tools.

6
docker/.env vendored Normal file
View File

@@ -0,0 +1,6 @@
LOCAL_BOOK_DIR=/home/user/pyShelf/Books
PORT=8088
POSTGRES_VER=12.2
POSTGRES_USER=pyshelf
POSTGRES_PASSWORD=pyshelf
POSTGRES_DB=pyshelf

20
docker/Dockerfile vendored Normal file
View File

@@ -0,0 +1,20 @@
# docker build -t ubuntu1604py36
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y
RUN apt-get install -y build-essential python3.8 python3.8-dev python3-pip python3.8-venv && apt-get install -y git
# update pip
RUN python3 -m pip install wheel
RUN git clone https://github.com/hat/pyShelf.git /usr/src/app/
RUN python3 -m pip install -r /usr/src/app/requirements.txt
EXPOSE 8000
WORKDIR /usr/src/app/src/
#RUN ../docker/scripts/wait-for-it.sh db:5432
RUN python3 manage.py migrate
#RUN python3 manage.py migrate interface
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]

30
docker/docker-compose.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
version: "3.7"
services:
db:
image: "postgres:${POSTGRES_VER}"
environment:
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
- "POSTGRES_USER=${POSTGRES_USER}"
- "POSTGRES_DB=${POSTGRES_DB}"
volumes:
- ./postgres_data/:/var/lib/postgresql/data/
pyshelf:
build:
context: ./
dockerfile: Dockerfile
volumes:
- "${LOCAL_BOOK_DIR}:/usr/src/app/Books"
# - "./cron/root:/etc/crontabs/root"
# - "./scripts/wait-for-it.sh:/usr/src/app/src/"
ports:
- "${PORT}:8000"
depends_on:
- db
networks:
default:
driver: bridge
ipam:
config:
- subnet: 10.20.20.0/24

View File

@@ -100,6 +100,8 @@ DATABASES = {
"NAME": CONFIG.catalogue_db, "NAME": CONFIG.catalogue_db,
"USER": "pyshelf", "USER": "pyshelf",
"PASSWORD": CONFIG.password, "PASSWORD": CONFIG.password,
"HOST": CONFIG.db_host,
"PORT": CONFIG.db_port,
} }
} }
# Session # Session