Merge pull request #2202 from SkynetLabs/allow-relative-call-to-dc-script

allow relative call to dc script
This commit is contained in:
Matthew Sevey 2022-08-15 09:47:59 -04:00 committed by GitHub
commit 7deaf1c0b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

31
dc
View File

@ -5,56 +5,57 @@
# would use docker-compose with the only difference being that you don't need to specify compose files. For more # would use docker-compose with the only difference being that you don't need to specify compose files. For more
# information you can run `./dc` or `./dc help`. # information you can run `./dc` or `./dc help`.
if [ -f .env ]; then # get current working directory of this script and prefix all files with it to
OLD_IFS=$IFS # be able to call this script from anywhere and not only root directory of
IFS=$'\n' # skynet-webportal project
for x in $(grep -v '^#.*' .env); do export $x; done cwd="$(dirname -- "$0";)";
IFS=$OLD_IFS
fi # get portal modules configuration from .env file (if defined more than once, the last one is used)
PORTAL_MODULES=$(grep -e "^PORTAL_MODULES=" ${cwd}.env | tail -1 | sed "s/PORTAL_MODULES=//")
# include base docker compose file # include base docker compose file
COMPOSE_FILES="-f docker-compose.yml" COMPOSE_FILES="-f ${cwd}/docker-compose.yml"
for i in $(seq 1 ${#PORTAL_MODULES}); do for i in $(seq 1 ${#PORTAL_MODULES}); do
# accounts module - alias "a" # accounts module - alias "a"
if [[ ${PORTAL_MODULES:i-1:1} == "a" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "a" ]]; then
COMPOSE_FILES+=" -f docker-compose.mongodb.yml -f docker-compose.accounts.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.accounts.yml"
fi fi
# blocker module - alias "b" # blocker module - alias "b"
if [[ ${PORTAL_MODULES:i-1:1} == "b" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "b" ]]; then
COMPOSE_FILES+=" -f docker-compose.mongodb.yml -f docker-compose.blocker.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml"
fi fi
# jaeger module - alias "j" # jaeger module - alias "j"
if [[ ${PORTAL_MODULES:i-1:1} == "j" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "j" ]]; then
COMPOSE_FILES+=" -f docker-compose.jaeger.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.jaeger.yml"
fi fi
# malware-scanner module - alias "s" # malware-scanner module - alias "s"
if [[ ${PORTAL_MODULES:i-1:1} == "s" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "s" ]]; then
COMPOSE_FILES+=" -f docker-compose.blocker.yml -f docker-compose.mongodb.yml -f docker-compose.malware-scanner.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.malware-scanner.yml"
fi fi
# mongodb module - alias "m" # mongodb module - alias "m"
if [[ ${PORTAL_MODULES:i-1:1} == "m" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "m" ]]; then
COMPOSE_FILES+=" -f docker-compose.mongodb.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml"
fi fi
# abuse-scanner module - alias "u" # abuse-scanner module - alias "u"
if [[ ${PORTAL_MODULES:i-1:1} == "u" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "u" ]]; then
COMPOSE_FILES+=" -f docker-compose.mongodb.yml -f docker-compose.blocker.yml -f docker-compose.abuse-scanner.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.abuse-scanner.yml"
fi fi
# pinner module - alias "p" # pinner module - alias "p"
if [[ ${PORTAL_MODULES:i-1:1} == "p" ]]; then if [[ ${PORTAL_MODULES:i-1:1} == "p" ]]; then
COMPOSE_FILES+=" -f docker-compose.mongodb.yml -f docker-compose.pinner.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.pinner.yml"
fi fi
done done
# override file if exists # override file if exists
if [[ -f docker-compose.override.yml ]]; then if [[ -f docker-compose.override.yml ]]; then
COMPOSE_FILES+=" -f docker-compose.override.yml" COMPOSE_FILES+=" -f ${cwd}/docker-compose.override.yml"
fi fi
docker-compose $COMPOSE_FILES $@ docker-compose $COMPOSE_FILES $@