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

local mount, profiles and new docs #152

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ example/private/*
example_sp/djangosaml2_sp/sqlite3.db
project/*
docker-example/*
Docker-compose/satosa/*
Docker-compose/djangosaml2_sp/*
Docker-compose/mongo/db/*
26 changes: 6 additions & 20 deletions Docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ services:
MONGO_INITDB_ROOT_USERNAME: "${MONGO_DBUSER:-satosa}"
MONGO_INITDB_ROOT_PASSWORD: "${MONGO_DBPASSWORD:-thatpassword}"
volumes:
- mongodata:/data/db
- /usr/share/zoneinfo/Europe/Rome:/etc/localtime:ro
peppelinux marked this conversation as resolved.
Show resolved Hide resolved
- ./mongo/db:/data/db
- ./mongo/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh
ports:
- '27017-27019:27017-27019'
Expand All @@ -34,17 +33,16 @@ services:
## START: PARTE NUOVA
django_sp:
build:
context: ../
context: ../
args:
- NODE_ENV=local
- NODE_ENV=local
dockerfile: example_sp/django.Dockerfile
container_name: django_sp
#restart: always
working_dir: /django_sp
entrypoint: "sh ../entrypoint.sh"
volumes:
- /usr/share/zoneinfo/Europe/Rome:/etc/localtime:ro
- ../example_sp/djangosaml2_sp:/django_sp:rw
- ./djangosaml2_sp:/django_sp:rw
ports:
- "8000:8000"
networks:
Expand Down Expand Up @@ -110,8 +108,7 @@ services:
ports:
- "10000:10000"
volumes:
- /usr/share/zoneinfo/Europe/Rome:/etc/localtime:ro
- ../docker-example:/satosa_proxy:rw
- ./satosa:/satosa_proxy:rw
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

satosa -> project?

I agree that docker-example is too much related to the demo purposes, while satosa is too much generic and might confuse the software/application name with the local configuration, I suppose that project or any other similar alternative might better explain the purpose of that folder

working_dir: /satosa_proxy
entrypoint: "sh entrypoint.sh"
networks:
Expand All @@ -136,7 +133,7 @@ services:
- ./nginx/50x.html:/usr/share/nginx/html/50x.html:ro
- ./nginx/404.html:/usr/share/nginx/html/404.html:ro
- ./nginx/403.html:/usr/share/nginx/html/403.html:ro
- nginx_certs:/etc/nginx/certs:ro
- ./nginx/certs:/etc/nginx/certs:ro
- ../docker-example/static:/var/www/html
networks:
- satosa-saml2spid
Expand All @@ -150,17 +147,6 @@ services:
- "8443:8443"
networks:
- satosa-saml2spid

volumes:

mongodata:
name: satosa-saml2spid_mongodata
external: true

nginx_certs:
name: satosa-saml2spid_nginx_certs
external: true

networks:
satosa-saml2spid:
name: satosa-saml2spid
Empty file.
49 changes: 0 additions & 49 deletions Docker-compose/rm-persistent-volumes.sh

This file was deleted.

91 changes: 55 additions & 36 deletions Docker-compose/run-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,65 @@
#!/bin/bash

function create-volume {
if [ ! "$(docker volume ls -q -f name=$1)" ]
then
echo -e "Il volume $1 non esiste, lo creo! \n"
docker volume create --name=$1
echo -e "\n"
if [[ ! -z "$2" ]]
then
echo -e "Ho creato il volume e ci copio i dati da $2 \n"
sudo cp -R $2* `docker volume inspect $1 | jq .[0].Mountpoint | sed 's/"//g'`
fi
else
echo -e "Il volume $1 esiste, non faccio nulla! \n"
fi
function clean_data {
rm -Rf ./mongo/db/*
rm -Rf ./satosa/*
rm -Rf ./djangosaml2_sp/*
}

create-volume satosa-saml2spid_nginx_certs nginx/certs/
create-volume satosa-saml2spid_mongodata
function initialize_satosa {
mkdir -p ./satosa
mkdir -p ./djangosaml2_sp
mkdir -p ./mongo/db

echo -e "\n"

echo -e "Provo a scaricare le nuove versioni. \n"

docker compose -f docker-compose.yml pull

echo -e "\n"

echo -e "Provo a fare il down della composizione. \n"

docker compose -f docker-compose.yml down -v

echo -e "\n"

echo -e "Tiro su la composizione, in caso, con le nuove versioni delle immagini. \n"
if [ ! -f ./satosa/proxy_conf.yaml ]; then cp -R ../example/* ./satosa/ ; else echo 'satosa directory is already initialized' ; fi
if [ ! -f ./djangosaml2_sp/run.sh ]; then cp -R ../example_sp/djangosaml2_sp/* ./djangosaml2_sp ; else echo 'djangosaml2_sp directory is already initialided' ; fi
}

docker compose -f docker-compose.yml build django_sp
function start {
echo -e "Provo a scaricare le nuove versioni. \n"
docker compose -f docker-compose.yml pull
echo -e "\n"
echo -e "Provo a fare il down della composizione. \n"
docker compose -f docker-compose.yml down -v
echo -e "\n"
echo -e "Tiro su la composizione, in caso, con le nuove versioni delle immagini. \n"
docker compose -f docker-compose.yml build django_sp
docker compose -f docker-compose.yml up --wait --wait-timeout 60
echo -e "\n"
echo -e "Completato. Per visionare i logs: 'docker-compose -f docker-compose.yml logs -f'"
exit 0
}

docker compose -f docker-compose.yml up -d --wait --wait-timeout 60
function help {
echo ""
echo "### run-docker-compose.sh ###"
echo ""
echo "initialize and start Satosa-Saml2Spid"
echo ""
echo "Option"
echo "-f Force clean and reinitialize data for Satosa, MongoDB and Djangosaml2_SP"
echo "-h Print this help"
echo ""
}

echo -e "\n"
while getopts ":fh" opt; do
case ${opt} in
f)
clean_data
;;
h)
help
exit 0
;;
?)
echo "Invalid option: -${OPTARG}."
echo ""
help
exit 1
;;
esac
done
initialize_satosa
start

echo -e "Completato. Per visionare i logs: 'docker-compose -f docker-compose.yml logs -f'"

exit 0
1 change: 1 addition & 0 deletions Docker-compose/satosa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
Loading