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

Feat: instruction for Windows WSL #146

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

## Requirements

The following instructions and provided scripts are intended to be used on a GNU/Linux based system. Success on Windows based system is currently not guaranteed.

In order to execute the run script you need:

* jq
Expand Down
68 changes: 54 additions & 14 deletions Docker-compose/run-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,63 @@
#!/bin/bash

VOLUME_ALREADY_EXISTS=10
VOLUME_CREATION_FAIL=20

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
if [ ! "$(docker volume ls -q -f name=$1)" ]; then
echo -e "\nCreazione del docker volume $1"
docker volume create --name=$1
res=$?
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
else
echo -e "\nIgnorata creazione del docker volume $1: volume gia' esistente"
return $VOLUME_ALREADY_EXISTS
fi
return 0
}

function create-volume-with-data {
create-volume $1
res=$?
if [[ $res != 0 ]]; then
# skip data initialization if the volume creation fails or if it already exists
return $res; fi
echo -e "\nInizializzazione del docker volume $1 con dati provenienti da $2"
volume_mountpoint=$(docker volume inspect $1 | jq .[0].Mountpoint | sed 's/"//g')
sudo cp -R $2* $volume_mountpoint
res=$?
if [[ $res != 0 ]]; then
echo -e "\nFallback: inizializzazione del docker volume per creazione container temporaneo: questa operazione potrebbe richiedere un po' di tempo..."
tmp_container_name="tmp-$RANDOM$RANDOM$RANDOM"
docker run -d --rm --name $tmp_container_name -v $1:/root alpine tail -f /dev/null
res=$?
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
docker cp $2/. $tmp_container_name:/root/
res=$?
docker stop $tmp_container_name
if [[ $res != 0 ]]; then
return $VOLUME_CREATION_FAIL; fi
fi
echo -e "\nInizializzazione del docker volume $1 terminata"
return 0
}

create-volume satosa-saml2spid_nginx_certs nginx/certs/
create-volume-with-data satosa-saml2spid_nginx_certs nginx/certs/
res=$?
if [[ $res == $VOLUME_CREATION_FAIL ]]; then
echo -e "\nERRORE: setup docker volumes fallita\n"
return 1
fi

create-volume satosa-saml2spid_mongodata
res=$?
if [[ $res == $VOLUME_CREATION_FAIL ]]; then
echo -e "\nERRORE: setup docker volumes fallita\n"
return 1
fi


echo -e "\n"

Expand Down
Loading