From f68e1638fc2ebf2d0e6643c4f0086cd6dc0dc270 Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 31 Oct 2023 11:00:08 +0100 Subject: [PATCH] idhub docker temp because of WIP on sso branches errors for musician and orchestra and final verification for devicehub only idhub is working --- Makefile | 23 ++++++++++++++--------- README.md | 6 ++++++ docker-compose_idhub-temp.yml | 18 ++++++++++++++++++ docker/idhub.Dockerfile | 17 +++++++++++++++++ docker/idhub.entrypoint.sh | 29 +++++++++++++++++++++++++++++ idhub_build.sh | 15 +++++++++++++++ 6 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 docker-compose_idhub-temp.yml create mode 100644 docker/idhub.Dockerfile create mode 100755 docker/idhub.entrypoint.sh create mode 100755 idhub_build.sh diff --git a/Makefile b/Makefile index 29fcf0a..2ae24df 100644 --- a/Makefile +++ b/Makefile @@ -18,30 +18,35 @@ orchestra_image := ${project}/orchestra:${orchestra_tag} musician_branch := `git -C django-musician branch --show-current` musician_commit := `git -C django-musician log -1 --format=%h` -musician_tag := ${orchestra_branch}__${musician_commit} +musician_tag := ${musician_branch}__${musician_commit} musician_image := ${project}/musician:${musician_tag} #### # idhub image tag #### -idhub_branch := `git -C django-idhub branch --show-current` -idhub_commit := `git -C django-idhub log -1 --format=%h` -idhub_tag := ${orchestra_branch}__${idhub_commit} +idhub_branch := `git -C IdHub branch --show-current` +idhub_commit := `git -C IdHub log -1 --format=%h` +idhub_tag := ${idhub_branch}__${idhub_commit} idhub_image := ${project}/idhub:${idhub_tag} docker_build: - docker build -f docker/orchestra.Dockerfile -t ${orchestra_image} . - docker build -f docker/musician.Dockerfile -t ${musician_image} . + #docker build -f docker/orchestra.Dockerfile -t ${orchestra_image} . + #docker build -f docker/musician.Dockerfile -t ${musician_image} . + docker build -f docker/idhub.Dockerfile -t ${idhub_image} . + @printf "\n##########################\n" + @printf "\nimage: ${orchestra_image}\n" + @printf "\nimage: ${musician_image}\n" + @printf "\nimage: ${idhub_image}\n" + @printf "\ndocker images built\n" + @printf "\n##########################\n\n" docker_publish: docker push ${orchestra_image} docker push ${musician_image} + docker push ${idhub_image} .PHONY: docker docker: $(MAKE) docker_build $(MAKE) docker_publish - @printf "\nimage: ${orchestra_image}\n" - @printf "\nimage: ${musician_image}\n" - @printf "\ndocker images built and published\n" diff --git a/README.md b/README.md index 12c95fb..defe9d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ docker files and integrations +# idhub + +use script `./idhub_build.sh` to rebuild it locally + +TODO: incorporate to general docker compose + # deploy everything in localhost note: right now the same applies for localhost and reachable deployments diff --git a/docker-compose_idhub-temp.yml b/docker-compose_idhub-temp.yml new file mode 100644 index 0000000..cc2b837 --- /dev/null +++ b/docker-compose_idhub-temp.yml @@ -0,0 +1,18 @@ +version: "3.9" +services: + + idhub: + init: true + image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/idhub:main__233d8df + environment: + - SECRET_KEY=${IDHUB_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd} + - ALLOWED_HOSTS=${IDHUB_ALLOWED_HOSTS:-*} + - STATIC_ROOT=${IDHUB_STATIC_ROOT:-/static/} + - MEDIA_ROOT=${IDHUB_MEDIA_ROOT:-/media/} + - PORT=${IDHUB_PORT:-7000} + - DJANGO_SUPERUSER_USERNAME=${IDHUB_USER} + - DJANGO_SUPERUSER_PASSWORD=${IDHUB_PASSWD} + - DJANGO_SUPERUSER_EMAIL=${IDHUB_EMAIL} + - DEPLOYMENT=${IDHUB_DEPLOYMENT} + ports: + - 7000:7000 diff --git a/docker/idhub.Dockerfile b/docker/idhub.Dockerfile new file mode 100644 index 0000000..40b9490 --- /dev/null +++ b/docker/idhub.Dockerfile @@ -0,0 +1,17 @@ +FROM debian:bullseye-slim + +RUN apt update && apt-get install -y \ + python3-minimal \ + python3-pip \ + python3-dev \ + python-is-python3 + +WORKDIR /home + +RUN python3 -m pip install --upgrade pip + +COPY IdHub . +RUN pip install -r requirements.txt + +COPY docker/idhub.entrypoint.sh . +ENTRYPOINT sh ./idhub.entrypoint.sh diff --git a/docker/idhub.entrypoint.sh b/docker/idhub.entrypoint.sh new file mode 100755 index 0000000..60e990e --- /dev/null +++ b/docker/idhub.entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -e +set -u +set -x + +main() { + # go to the same path as the script + cd "$(dirname ${0})" + + # enable dev flags when DEVELOPMENT deployment + if [ "${DEPLOYMENT}" = 'DEVELOPMENT' ]; then + export DEBUG=True + export DEVELOPMENT=True + fi + + # 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 + #./manage.py collectstatic + + 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 + + ./manage.py runserver 0.0.0.0:${PORT} +} + +main "${@}" diff --git a/idhub_build.sh b/idhub_build.sh new file mode 100755 index 0000000..e52ced3 --- /dev/null +++ b/idhub_build.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e +set -u +# DEBUG +set -x + +main() { + idhub_dc_f='docker-compose_idhub-temp.yml' + docker compose -f ${idhub_dc_f} down -v \ + && make docker_build \ + && docker compose -f ${idhub_dc_f} up +} + +main "${@}"