piston/piston

77 lines
2.2 KiB
Plaintext
Raw Normal View History

2021-04-25 03:56:16 +02:00
#!/usr/bin/env bash
cd "$(dirname "$0")"
PISTON_ENV=$(cat .piston_env || echo dev)
docker_compose(){
if [ -f "docker-compose.$PISTON_ENV.yaml" ]; then
docker-compose -f "docker-compose.$PISTON_ENV.yaml" "$@"
else
docker-compose "$@"
fi
}
2021-04-25 05:04:01 +02:00
case $1 in
help)
echo "=== Piston Management ==="
echo "Current Environment: $PISTON_ENV"
echo
echo "Commands:"
echo " select <environment> Select the environment"
echo " docker_compose <args...> Interact directly with the docker-compose for the selected environment"
echo
echo " start Starts piston"
echo " stop Stops piston"
echo " restart Restarts piston"
echo
echo " update Fetches and applies latest updates"
echo
echo " <args..> Passthrough to piston cli tool"
echo
echo "Development Commands:"
if [ $PISTON_ENV == dev ]; then
echo " clean-pkgs Clean any package build artifacts on disk"
echo " clean-repo Remove all packages from local repo"
echo " build-pkg <package> <version> Build a package"
else
echo " Switch to developement environment for more info"
echo " > piston switch dev"
fi
2021-04-25 05:04:01 +02:00
;;
select) echo "$2" > .piston_env ;;
docker_compose) shift; docker_compose "$@";;
restart) docker_compose restart ;;
start) docker_compose up -d ;;
stop) docker_compose down ;;
2021-04-25 05:04:01 +02:00
update)
git pull
docker_compose pull
docker_compose up -d
2021-04-25 05:04:01 +02:00
;;
clean-pkgs) git clean -fqXd packages ;;
clean-repo) git clean -fqXd repo ;;
build-pkg)
PKGSLUG="$2-$3"
echo "Building $PKGSLUG"
echo "Ensuring latest builder image"
docker build repo -t piston-repo-builder
docker run -v "$(realpath $(dirname "$0")):/piston" piston-repo-builder --no-server $PKGSLUG
2021-04-25 05:04:01 +02:00
;;
*)
cd cli
npm i > /dev/null
cd ../
node cli/index.js "$@"
;;
2021-04-25 05:04:01 +02:00
esac