From df057359796abeaa23756781fbd90c1cfb4c89c6 Mon Sep 17 00:00:00 2001 From: pedro Date: Fri, 1 Dec 2023 10:10:11 +0100 Subject: [PATCH] idhub: make it more dev env friendly now idhub docker just has the dev env, you need to map the idhub repo as a volume (there is a friendly error handling for that) --- docker-compose_idhub-temp.yml | 2 ++ docker/idhub.Dockerfile | 10 ++++---- docker/idhub.entrypoint.sh | 46 +++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/docker-compose_idhub-temp.yml b/docker-compose_idhub-temp.yml index 1d0d274..48d8b71 100644 --- a/docker-compose_idhub-temp.yml +++ b/docker-compose_idhub-temp.yml @@ -24,3 +24,5 @@ services: - EMAIL_BACKEND=${IDHUB_EMAIL_BACKEND} ports: - 7000:7000 + volumes: + - ./IdHub:/opt/idhub diff --git a/docker/idhub.Dockerfile b/docker/idhub.Dockerfile index 40b9490..de6bddd 100644 --- a/docker/idhub.Dockerfile +++ b/docker/idhub.Dockerfile @@ -6,12 +6,12 @@ RUN apt update && apt-get install -y \ python3-dev \ python-is-python3 -WORKDIR /home +WORKDIR /opt/idhub RUN python3 -m pip install --upgrade pip -COPY IdHub . -RUN pip install -r requirements.txt +COPY IdHub/requirements.txt / +RUN pip install -r /requirements.txt -COPY docker/idhub.entrypoint.sh . -ENTRYPOINT sh ./idhub.entrypoint.sh +COPY docker/idhub.entrypoint.sh / +ENTRYPOINT sh /idhub.entrypoint.sh diff --git a/docker/idhub.entrypoint.sh b/docker/idhub.entrypoint.sh index 62b444f..2e70c72 100755 --- a/docker/idhub.entrypoint.sh +++ b/docker/idhub.entrypoint.sh @@ -5,25 +5,45 @@ set -u set -x main() { - # go to the same path as the script - cd "$(dirname ${0})" + idhub_dir='/opt/idhub' + cd "${idhub_dir}" - # move the migrate thing in docker entrypoint - # inspired by https://medium.com/analytics-vidhya/django-with-docker-and-docker-compose-python-part-2-8415976470cc - ./manage.py migrate + if [ ! -f "./manage.py" ]; then + cat <&2 + ./manage.py initial_datas + else + printf "creating superuser \n user: ${DJANGO_SUPERUSER_USERNAME}\n password: ${DJANGO_SUPERUSER_PASSWORD}\n email: ${DJANGO_SUPERUSER_EMAIL}\n" >&2 + ## thanks https://stackoverflow.com/questions/6244382/how-to-automate-createsuperuser-on-django/59467533#59467533 + ./manage.py createsuperuser --no-input + fi + fi # enable dev flags when DEVELOPMENT deployment if [ "${DEPLOYMENT}" = 'DEVELOPMENT' ]; then export DEBUG=True export DEVELOPMENT=True - - printf "This is DEVELOPMENT DEPLOYMENT: including demo hardcoded data\n creating initial Datas\n" >&2 - ./manage.py initial_datas - - else - printf "creating superuser \n user: ${DJANGO_SUPERUSER_USERNAME}\n password: ${DJANGO_SUPERUSER_PASSWORD}\n email: ${DJANGO_SUPERUSER_EMAIL}\n" >&2 - ## thanks https://stackoverflow.com/questions/6244382/how-to-automate-createsuperuser-on-django/59467533#59467533 - ./manage.py createsuperuser --no-input fi #./manage.py collectstatic