mirror of
https://github.com/ChronosX88/openkeepd.git
synced 2024-11-23 14:32:19 +00:00
chore: Add scripts for setting up development environment
This commit is contained in:
parent
020563605a
commit
a547a2e209
82
devzone/devzone.sh
Executable file
82
devzone/devzone.sh
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
clear_postgresql() {
|
||||||
|
echo "Clearing PostgreSQL..."
|
||||||
|
for dir in `ls ${SCRIPT_PATH}/postgresql/data`; do
|
||||||
|
echo -e "\t${SCRIPT_PATH}/postgresql/data/${dir}"
|
||||||
|
rm -rf ${SCRIPT_PATH}/postgresql/data/${dir}/*
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
down() {
|
||||||
|
echo "Cleaning up development environment..."
|
||||||
|
docker-compose down --remove-orphans
|
||||||
|
clear_postgresql
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
echo "Getting development environment up and running with docker-compose..."
|
||||||
|
# ToDo: checks?
|
||||||
|
USER_ID=$USER_ID GROUP_ID=$GROUP_ID docker-compose 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 "\tclear_postgresql\t\tClears PostgreSQL persistent data directories from data."
|
||||||
|
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
|
||||||
|
clear_postgresql)
|
||||||
|
clear_postgresql
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
down
|
||||||
|
;;
|
||||||
|
run)
|
||||||
|
run
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
14
devzone/docker-compose.yaml
Normal file
14
devzone/docker-compose.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
version: "2.4"
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgresql:
|
||||||
|
image: "postgres:11.5"
|
||||||
|
ports:
|
||||||
|
- "15432:5432"
|
||||||
|
volumes:
|
||||||
|
- "./postgresql/data:/var/lib/postgresql/data"
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: cadmium
|
||||||
|
POSTGRES_PASSWORD: cadmium
|
||||||
|
POSTGRES_DB: cadmium
|
||||||
|
user: ${USER_ID}
|
Loading…
Reference in New Issue
Block a user