diff --git a/README.md b/README.md index 5328acc..3cfe4fe 100755 --- a/README.md +++ b/README.md @@ -114,6 +114,34 @@ All configuration is now handled by the installer. 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 #### Organizational tools. diff --git a/config.json b/config.json index 48e6c6f..2347e08 100755 --- a/config.json +++ b/config.json @@ -1 +1 @@ -{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "/home/raelon/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001"} +{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "/home/raelon/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001"} \ No newline at end of file diff --git a/docker/.env b/docker/.env new file mode 100644 index 0000000..8c02342 --- /dev/null +++ b/docker/.env @@ -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 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..ebc5e95 --- /dev/null +++ b/docker/Dockerfile @@ -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"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..4940c92 --- /dev/null +++ b/docker/docker-compose.yml @@ -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 diff --git a/src/frontend/settings.py b/src/frontend/settings.py index b948105..60d1ce9 100755 --- a/src/frontend/settings.py +++ b/src/frontend/settings.py @@ -100,6 +100,8 @@ DATABASES = { "NAME": CONFIG.catalogue_db, "USER": "pyshelf", "PASSWORD": CONFIG.password, + "HOST": CONFIG.db_host, + "PORT": CONFIG.db_port, } } # Session