0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00
penpot/manage.sh

205 lines
5.1 KiB
Bash
Raw Normal View History

2016-11-20 14:08:24 -05:00
#!/usr/bin/env bash
set -e
2016-11-20 14:08:24 -05:00
REV=`git log -n 1 --pretty=format:%h -- docker/`
DEVENV_IMGNAME="uxbox-devenv"
2016-11-20 14:08:24 -05:00
function build-devenv {
echo "Building development image $DEVENV_IMGNAME:latest with UID $EXTERNAL_UID..."
local EXTERNAL_UID=${1:-$(id -u)}
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml build \
--force-rm --build-arg EXTERNAL_UID=$EXTERNAL_UID
2016-11-20 14:08:24 -05:00
}
function build-devenv-if-not-exists {
if [[ ! $(docker images $DEVENV_IMGNAME:latest -q) ]]; then
build-devenv $@
2016-11-20 14:08:24 -05:00
fi
2019-07-03 10:49:15 -05:00
}
function start-devenv {
build-devenv-if-not-exists $@;
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml up -d;
}
2016-11-20 14:08:24 -05:00
function stop-devenv {
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml stop -t 2;
}
function drop-devenv {
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml down -t 2 -v;
echo "Clean old development image $DEVENV_IMGNAME..."
docker images $DEVENV_IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi
}
function run-devenv {
if [[ ! $(docker ps -f "name=uxbox-devenv-main" -q) ]]; then
start-devenv
fi
2019-02-20 15:24:03 -05:00
docker exec -ti uxbox-devenv-main /home/start-tmux.sh
}
2020-09-09 08:49:06 -05:00
function build {
build-devenv-if-not-exists;
local IMAGE=$DEVENV_IMGNAME:latest;
2020-09-09 08:49:06 -05:00
docker volume create uxboxdev_user_data;
echo "Running development image $IMAGE to build frontend."
docker run -t --rm \
2020-09-09 08:49:06 -05:00
--mount source=uxboxdev_user_data,type=volume,target=/home/uxbox/ \
--mount source=`pwd`,type=bind,target=/home/uxbox/uxbox \
2020-09-09 08:49:06 -05:00
-w /home/uxbox/uxbox/$1 \
$IMAGE ./scripts/build.sh
}
2020-09-09 08:49:06 -05:00
function build-frontend {
build "frontend";
}
2020-09-09 08:49:06 -05:00
function build-exporter {
build "exporter";
}
function build-backend {
2020-09-09 08:49:06 -05:00
build "backend";
}
function build-bundle {
build "frontend";
build "exporter";
build "backend";
rm -rf ./bundle
mkdir -p ./bundle
mv ./frontend/target/dist ./bundle/frontend
mv ./backend/target/dist ./bundle/backend
mv ./exporter/target ./bundle/exporter
NAME="uxbox-$(date '+%Y.%m.%d-%H%M')"
pushd bundle/
tar -cvf ../$NAME.tar *;
popd
xz -vez4f -T4 $NAME.tar
}
2019-12-09 10:29:26 -05:00
function log-devenv {
docker-compose -p uxboxdev -f docker/devenv/docker-compose.yaml logs -f --tail=50
2019-12-09 10:29:26 -05:00
}
2020-09-09 08:49:06 -05:00
function build-testenv {
local BUNDLE_FILE=$1;
local BUNDLE_FILE_PATH=`readlink -f $BUNDLE_FILE`;
echo "Building testenv with bundle: $BUNDLE_FILE_PATH."
if [ ! -f $BUNDLE_FILE ]; then
echo "File $BUNDLE_FILE does not exists."
fi
rm -rf ./docker/testenv/bundle;
mkdir -p ./docker/testenv/bundle;
pushd ./docker/testenv/bundle;
tar xvf $BUNDLE_FILE_PATH;
popd
pushd ./docker/testenv;
docker-compose -p uxbox-testenv -f ./docker-compose.yaml build
popd
}
function start-testenv {
pushd ./docker/testenv;
docker-compose -p uxbox-testenv -f ./docker-compose.yaml up
popd
}
2016-11-20 14:08:24 -05:00
function usage {
echo "UXBOX build & release manager v$REV"
echo "USAGE: $0 OPTION"
2019-05-15 17:48:09 -05:00
echo "Options:"
# echo "- clean Stop and clean up docker containers"
# echo ""
echo "- build-devenv Build docker development oriented image; (can specify external user id in parameter)"
echo "- start-devenv Start the development oriented docker-compose service."
echo "- stop-devenv Stops the development oriented docker-compose service."
echo "- drop-devenv Remove the development oriented docker-compose containers, volumes and clean images."
echo "- run-devenv Attaches to the running devenv container and starts development environment"
echo " based on tmux (frontend at localhost:3449, backend at localhost:6060)."
echo ""
echo "- run-all-tests Execute unit tests for both backend and frontend."
echo "- run-frontend-tests Execute unit tests for frontend only."
echo "- run-backend-tests Execute unit tests for backend only."
2016-11-20 14:08:24 -05:00
}
case $1 in
## devenv related commands
build-devenv)
build-devenv ${@:2}
;;
start-devenv)
start-devenv ${@:2}
2016-11-20 14:08:24 -05:00
;;
run-devenv)
run-devenv ${@:2}
;;
stop-devenv)
stop-devenv ${@:2}
;;
drop-devenv)
drop-devenv ${@:2}
;;
2019-12-09 10:29:26 -05:00
log-devenv)
log-devenv ${@:2}
;;
2020-09-09 08:49:06 -05:00
# Test Env
start-testenv)
start-testenv
;;
build-testenv)
build-testenv ${@:2}
;;
## testin related commands
# run-all-tests)
# run-all-tests ${@:2}
# ;;
# run-frontend-tests)
# run-frontend-tests ${@:2}
# ;;
# run-backend-tests)
# run-backend-tests ${@:2}
# ;;
2019-08-08 14:24:43 -05:00
# production builds
build-frontend)
build-frontend
2019-07-04 03:41:32 -05:00
;;
build-backend)
build-backend
;;
build-exporter)
build-exporter
;;
2020-09-09 08:49:06 -05:00
build-bundle)
build-bundle
;;
2016-11-20 14:08:24 -05:00
*)
usage
;;
esac