idhub docker temp

because of WIP on sso branches errors for musician and orchestra

and final verification for devicehub

only idhub is working
This commit is contained in:
pedro 2023-10-31 11:00:08 +01:00
parent 0359759848
commit f68e1638fc
6 changed files with 99 additions and 9 deletions

View File

@ -18,30 +18,35 @@ orchestra_image := ${project}/orchestra:${orchestra_tag}
musician_branch := `git -C django-musician branch --show-current` musician_branch := `git -C django-musician branch --show-current`
musician_commit := `git -C django-musician log -1 --format=%h` 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} musician_image := ${project}/musician:${musician_tag}
#### ####
# idhub image tag # idhub image tag
#### ####
idhub_branch := `git -C django-idhub branch --show-current` idhub_branch := `git -C IdHub branch --show-current`
idhub_commit := `git -C django-idhub log -1 --format=%h` idhub_commit := `git -C IdHub log -1 --format=%h`
idhub_tag := ${orchestra_branch}__${idhub_commit} idhub_tag := ${idhub_branch}__${idhub_commit}
idhub_image := ${project}/idhub:${idhub_tag} idhub_image := ${project}/idhub:${idhub_tag}
docker_build: docker_build:
docker build -f docker/orchestra.Dockerfile -t ${orchestra_image} . #docker build -f docker/orchestra.Dockerfile -t ${orchestra_image} .
docker build -f docker/musician.Dockerfile -t ${musician_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_publish:
docker push ${orchestra_image} docker push ${orchestra_image}
docker push ${musician_image} docker push ${musician_image}
docker push ${idhub_image}
.PHONY: docker .PHONY: docker
docker: docker:
$(MAKE) docker_build $(MAKE) docker_build
$(MAKE) docker_publish $(MAKE) docker_publish
@printf "\nimage: ${orchestra_image}\n"
@printf "\nimage: ${musician_image}\n"
@printf "\ndocker images built and published\n"

View File

@ -1,5 +1,11 @@
docker files and integrations docker files and integrations
# idhub
use script `./idhub_build.sh` to rebuild it locally
TODO: incorporate to general docker compose
# deploy everything in localhost # deploy everything in localhost
note: right now the same applies for localhost and reachable deployments note: right now the same applies for localhost and reachable deployments

View File

@ -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

17
docker/idhub.Dockerfile Normal file
View File

@ -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

29
docker/idhub.entrypoint.sh Executable file
View File

@ -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 "${@}"

15
idhub_build.sh Executable file
View File

@ -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 "${@}"