Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First working draft docker-compose #53

Merged
merged 11 commits into from
Aug 3, 2020
Merged

First working draft docker-compose #53

merged 11 commits into from
Aug 3, 2020

Conversation

MartenBE
Copy link
Contributor

@MartenBE MartenBE commented Jul 30, 2020

This branch is based on the work already delivered by @hat .

TODO's

  • Make sure the application can handle it if the DB isn't ready or found (other solution is wait-for-it in docker, but it is better to solve the generic case). Partially solved as docker-compose supports depends, but the error still happens sometimes. Restarting docker -compose (docker -compose down and docker-compose up) manually a second time does fix the problem.
  • Remove everything involved with the installer. Solved.
  • Instead of pulling nginx in ourselves, use the uwsgi to connect to an external nginx container via docker-compose. This allows us to swith from ubuntu as base image to the python base image which has everything we need already included. This way we don't need to apt update/install anything ourselves.
  • Deduplicate options in both .env and config.json, or allow mounting the config.json file. This is especially important for the database variables (POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD).
  • Move the docker stuff into a docker subfolder. Solved: use docker-compose -f ./docker/development.docker-compose.yml up --build in the project root to start both pyshelf and the database.
  • Figure out how to make this work with dockerhub. Also figure out how to generate the image automatically after each release using CI. Solved: use the following commands in the project root to build and push the docker image to dockerhub:
    docker build -t pyshelf/pyshelf -f .\docker\Dockerfile .
    docker login
    docker push pyshelf/pyshelf
    
    The integration of this command with github CI should be done in a way which is most comfortable for @th3r00t . Perhaps https://docs.github.com/en/actions/language-and-framework-guides/publishing-docker-images is a solution?

The docker-compose here should only be given as an example. pyShelf should only be responsible for a pyShelf image on dockerhub. The docker-compose is normally written by the user himself, so he can decide which folder to use, which webserver, which database, etc. ... . Therefor, we should keep this as simple and generic as possible.

Example of the docker-compose.yml file:

version: "3.8"

services:
    db:
        image: "postgres"
        environment:
            - "POSTGRES_PASSWORD=pyshelf"
            - "POSTGRES_USER=pyshelf"
            - "POSTGRES_DB=pyshelf"
        volumes:
            - "db_data:/var/lib/postgresql/data/"

    pyshelf:
        image: "pyshelf/pyshelf"
        ports: 
            - "8080:8000"
        volumes:
            - "${LOCAL_BOOK_DIR}:/books"
        depends_on:
            - db

volumes:
    db_data:

Example of the .env file:

LOCAL_BOOK_DIR=/home/someone/books

@MartenBE MartenBE changed the title [WIP] First working draft docker-compose First working draft docker-compose Jul 31, 2020
@th3r00t th3r00t merged commit 8bece18 into th3r00t:development Aug 3, 2020
@MartenBE MartenBE deleted the docker branch August 3, 2020 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants