#!/bin/bash # The dc command is an alias to docker-compose which also scans the current portal configuration (as defined in .env) # and selects the right docker-compose files to include in the operation. You can use the command in the same way you # 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`. # get current working directory of this script and prefix all files with it to # be able to call this script from anywhere and not only root directory of # skynet-webportal project cwd="$(dirname -- "$0";)"; # get portal modules configuration from .env file (if defined more than once, the last one is used) if [[ -f "${cwd}/.env" ]]; then PORTAL_MODULES=$(grep -e "^PORTAL_MODULES=" ${cwd}/.env | tail -1 | sed "s/PORTAL_MODULES=//") fi # include base docker compose file COMPOSE_FILES="-f ${cwd}/docker-compose.yml" for i in $(seq 1 ${#PORTAL_MODULES}); do # accounts module - alias "a" if [[ ${PORTAL_MODULES:i-1:1} == "a" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.accounts.yml" fi # blocker module - alias "b" if [[ ${PORTAL_MODULES:i-1:1} == "b" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml" fi # jaeger module - alias "j" if [[ ${PORTAL_MODULES:i-1:1} == "j" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.jaeger.yml" fi # malware-scanner module - alias "s" if [[ ${PORTAL_MODULES:i-1:1} == "s" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.malware-scanner.yml" fi # mongodb module - alias "m" if [[ ${PORTAL_MODULES:i-1:1} == "m" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml" fi # abuse-scanner module - alias "u" if [[ ${PORTAL_MODULES:i-1:1} == "u" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.abuse-scanner.yml" fi # pinner module - alias "p" if [[ ${PORTAL_MODULES:i-1:1} == "p" ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.pinner.yml" fi done # override file if exists if [[ -f docker-compose.override.yml ]]; then COMPOSE_FILES+=" -f ${cwd}/docker-compose.override.yml" fi docker-compose $COMPOSE_FILES $@