Add devzone config

This commit is contained in:
ChronosX88 2021-04-06 16:54:49 +03:00
parent e6199a1a4f
commit 123610d33b
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
2 changed files with 79 additions and 0 deletions

69
devzone/devzone.sh Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Actually this isn't needed as we extract script path later and use it
# for everything, but anyway!
if [ "$0" != "./devzone.sh" ]; then
echo "This script should be launched as './devzone.sh'!"
exit 1
fi
# Check for OS first. On macOS greadlink should be used instead of
# readlink.
READLINK="/bin/readlink"
OS=$(uname -s)
if [ "${OS}" == "Darwin" ]; then
READLINK="/usr/local/bin/greadlink"
if [ ! -f "${READLINK}" ]; then
echo "GNU readlink is required for macOS. Please, install coreutils with brew."
exit 1
fi
fi
SCRIPT_PATH=$(dirname "`${READLINK} -f "${BASH_SOURCE}"`")
echo "devzone script path: ${SCRIPT_PATH}"
# This values might or might not be filled by OS.
# And it MUST NOT be filled on macOS. Docker is so convenient...
if [ "${OS}" != "Darwin" ]; then
USER_ID=$(id -u)
GROUP_ID=$(id -g)
else
echo "macOS users have no need in setting user and group ID"
fi
down() {
echo "Cleaning up development environment..."
docker-compose down --remove-orphans
}
run() {
echo "Getting development environment up and running with docker-compose..."
# ToDo: checks?
USER_ID=$USER_ID GROUP_ID=$GROUP_ID docker-compose -p devzone_zirconium up
if [ $? -ne 0 ]; then
echo "Something went wrong. Read previous messages carefully!"
exit 1
fi
echo "Development zone shutted down."
}
help() {
echo "Developers helper script."
echo ""
echo "Available subcommands:"
echo -e "\tdown\t\t\t\tClear development environment from data."
echo -e "\trun\t\t\t\tStart development zone required servers (databases, etc.)."
}
case $1 in
down)
down
;;
run)
run
;;
*)
help
;;
esac

View File

@ -0,0 +1,10 @@
version: "2.4"
services:
mongo:
image: "mongo:4.2.3"
ports:
- "27017-27019:27017-27019"
environment:
MONGO_INITDB_ROOT_USERNAME: "root"
MONGO_INITDB_ROOT_PASSWORD: "root"