Skip to content

Commit

Permalink
Added profile demo and dataentry, removed not required "restart: always"
Browse files Browse the repository at this point in the history
  • Loading branch information
MdreW committed Sep 8, 2024
1 parent 6b624ef commit 87c7f90
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
12 changes: 9 additions & 3 deletions Docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ services:
satosa-mongo:
image: mongo
container_name: satosa-mongo
restart: always
environment:
MONGO_INITDB_DATABASE: oidcop
MONGO_INITDB_ROOT_USERNAME: "${MONGO_DBUSER:-satosa}"
Expand All @@ -18,11 +17,15 @@ services:
- satosa-saml2spid

satosa-mongo-express:
profiles:
- demo
- dataentry
image: mongo-express
container_name: satosa-mongo-express
restart: always
ports:
- 8082:8081
depends_on:
- satosa-mongo
environment:
ME_CONFIG_BASICAUTH_USERNAME: satosauser
ME_CONFIG_BASICAUTH_PASSWORD: satosapw
Expand All @@ -33,13 +36,14 @@ services:
networks:
- satosa-saml2spid
django_sp:
profiles:
- demo
build:
context: ../
args:
- NODE_ENV=local
dockerfile: example_sp/django.Dockerfile
container_name: django_sp
#restart: always
working_dir: /django_sp
entrypoint: "sh ../entrypoint.sh"
volumes:
Expand Down Expand Up @@ -143,6 +147,8 @@ services:
environment:
- NGINX_HOST=${SATOSA_HOSTNAME:-localhost}
spid-samlcheck:
profiles:
- demo
image: italia/spid-saml-check
container_name: spid-samlcheck
ports:
Expand Down
48 changes: 34 additions & 14 deletions Docker-compose/run-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

export COMPOSE_PROFILES=demo
export SKIP_UPDATE=
function clean_data {
rm -Rf ./mongo/db/*
rm -Rf ./satosa/*
Expand All @@ -15,16 +16,21 @@ function initialize_satosa {
if [ ! -f ./djangosaml2_sp/run.sh ]; then cp -R ../example_sp/djangosaml2_sp/* ./djangosaml2_sp ; else echo 'djangosaml2_sp directory is already initialided' ; fi
}

function update {
if [[ -z "${SKIP_UPDATE}" ]]; then
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
fi
}

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
docker compose -f docker-compose.yml up --wait --wait-timeout 60 --remove-orphans
echo -e "\n"
echo -e "Completato. Per visionare i logs: 'docker-compose -f docker-compose.yml logs -f'"
exit 0
Expand All @@ -34,19 +40,32 @@ function help {
echo ""
echo "### run-docker-compose.sh ###"
echo ""
echo "initialize and start Satosa-Saml2Spid"
echo "initialize check update 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 "-p Set production profile: start satosa, nginx, mongo"
echo "-s Skip docker image update"
echo "-d Set data entry profile: start satosa, nginx, mongo, mongo-express"
echo " if isn't set -d or -p defatult demo profile is started"
echo " default demo profile start: satosa, nginx, mongo, mongo-express, django-sp, spid-saml-check"
}

while getopts ":fh" opt; do
while getopts ":fpdsh" opt; do
case ${opt} in
f)
clean_data
;;
p)
unset COMPOSE_PROFILES
;;
d)
COMPOSE_PROFILES=dataentry
;;
s)
SKIP_UPDATE=true
;;
h)
help
exit 0
Expand All @@ -60,6 +79,7 @@ while getopts ":fh" opt; do
esac
done
initialize_satosa
update
start

echo $SKIP_UPDATE

2 changes: 1 addition & 1 deletion Docker-compose/stop-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ echo -e "\n"

echo -e "Eseguo il down della composizione. \n"

docker compose -f docker-compose.yml down -v
docker compose -f docker-compose.yml --profile "*" down -v --remove-orphans

exit 0

0 comments on commit 87c7f90

Please sign in to comment.