Compare commits

...

2 commits

Author SHA1 Message Date
pedro f68e1638fc idhub docker temp
because of WIP on sso branches errors for musician and orchestra

and final verification for devicehub

only idhub is working
2023-10-31 11:00:08 +01:00
pedro 0359759848 orchestra & musician: use env namespace 2023-10-31 10:44:46 +01:00
8 changed files with 112 additions and 16 deletions

View file

@ -1,6 +1,12 @@
ORCHESTRA_SECRET_KEY= # ORCHESTRA
MUSICIAN_SECRET_KEY= ####
#ORCHESTRA_SECRET_KEY='uncomment-it-and-fill-this'
# MUSICIAN
####
#MUSICIAN_SECRET_KEY='uncomment-it-and-fill-this'
# specially useful if you want to deploy in a specific domain # specially useful if you want to deploy in a specific domain
#MUSICIAN_API_BASE_URL=https://orchestra.example.org #MUSICIAN_API_BASE_URL='https://orchestra.example.org'
#ALLOWED_HOSTS=musician.example.org #MUSICIAN_ALLOWED_HOSTS='musician.example.org'

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

@ -5,7 +5,7 @@ services:
init: true init: true
image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/orchestra:sso__533d749 image: dkr-dsg.ac.upc.edu/trustchain-oc1-orchestral/orchestra:sso__533d749
environment: environment:
- SECRET_KEY=${ORCHESTRA_SECRET_KEY:-123456} - SECRET_KEY=${ORCHESTRA_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd}
ports: ports:
- "9080:9080" - "9080:9080"
# TODO configure volumes # TODO configure volumes
@ -18,9 +18,9 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
environment: environment:
- SECRET_KEY=${MUSICIAN_SECRET_KEY:-123456} - SECRET_KEY=${MUSICIAN_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd}
- API_BASE_URL=${MUSICIAN_API_BASE_URL:-http://nginx-orchestra-api:3000} - API_BASE_URL=${MUSICIAN_API_BASE_URL:-http://nginx-orchestra-api:3000}
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-*} - ALLOWED_HOSTS=${MUSICIAN_ALLOWED_HOSTS:-*}
# TODO configure volumes # TODO configure volumes
#volumes: #volumes:
# - .:/home # - .:/home

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