Merge branch 'next-minor' into develop
This commit is contained in:
commit
ddaa5c0064
1 changed files with 35 additions and 25 deletions
|
|
@ -158,6 +158,16 @@ print_usage_full() {
|
||||||
|
|
||||||
# ----- Helper functions -----
|
# ----- Helper functions -----
|
||||||
|
|
||||||
|
dia_docker_compose() {
|
||||||
|
# Check permissions of docker socket and use sudo if needed
|
||||||
|
if [ -r "/var/run/docker.sock" ] && [ -w "/var/run/docker.sock" ]; then
|
||||||
|
docker-compose "$@"
|
||||||
|
else
|
||||||
|
echo "Attention: Docker socket not writable, using sudo for the docker command. You might be asked for your password now." >&2
|
||||||
|
sudo -E docker-compose "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
dia_fetch_upstream() {
|
dia_fetch_upstream() {
|
||||||
# Add and fetch upstream develop branch
|
# Add and fetch upstream develop branch
|
||||||
if ! git remote show | grep -q '^upstream$'; then
|
if ! git remote show | grep -q '^upstream$'; then
|
||||||
|
|
@ -181,12 +191,12 @@ exit_if_unconfigured() {
|
||||||
|
|
||||||
dia_is_running() {
|
dia_is_running() {
|
||||||
# Check if diaspora container is running
|
# Check if diaspora container is running
|
||||||
docker-compose ps --services --filter status=running | grep -qx 'diaspora'
|
dia_docker_compose ps --services --filter status=running | grep -qx 'diaspora'
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_is_db_running() {
|
dia_is_db_running() {
|
||||||
# Check if db container is running
|
# Check if db container is running
|
||||||
docker-compose ps --services --filter status=running | grep -qx $DIASPORA_DOCKER_DB
|
dia_docker_compose ps --services --filter status=running | grep -qx $DIASPORA_DOCKER_DB
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_get_db() {
|
dia_get_db() {
|
||||||
|
|
@ -199,14 +209,14 @@ dia_get_db() {
|
||||||
dia_build() {
|
dia_build() {
|
||||||
if [ $# -gt 0 ] && [ "$1" == "--no-cache" ]; then nocache="--no-cache"; fi
|
if [ $# -gt 0 ] && [ "$1" == "--no-cache" ]; then nocache="--no-cache"; fi
|
||||||
# Build the diaspora Docker container (diaspora:dev-latest)
|
# Build the diaspora Docker container (diaspora:dev-latest)
|
||||||
docker-compose build $nocache diaspora
|
dia_docker_compose build $nocache diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_bundle() {
|
dia_bundle() {
|
||||||
# Run bundle in order to install all gems into $DIASPORA_ROOT
|
# Run bundle in order to install all gems into $DIASPORA_ROOT
|
||||||
# Do not start database, not required and sometimes not yet configured
|
# Do not start database, not required and sometimes not yet configured
|
||||||
echo "Installing gems via bundler ..."
|
echo "Installing gems via bundler ..."
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm \
|
--rm \
|
||||||
--no-deps $1 \
|
--no-deps $1 \
|
||||||
-e DIA_NODB=1 \
|
-e DIA_NODB=1 \
|
||||||
|
|
@ -223,7 +233,7 @@ dia_clean() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
docker-compose down -v
|
dia_docker_compose down -v
|
||||||
if [ ! -z $dia_config_delete ]; then
|
if [ ! -z $dia_config_delete ]; then
|
||||||
rm "$DIASPORA_CONFIG_DIA" "$DIASPORA_CONFIG_DB"
|
rm "$DIASPORA_CONFIG_DIA" "$DIASPORA_CONFIG_DB"
|
||||||
fi
|
fi
|
||||||
|
|
@ -284,7 +294,7 @@ dia_config() {
|
||||||
dia_cucumber() {
|
dia_cucumber() {
|
||||||
# Run cucumber tests
|
# Run cucumber tests
|
||||||
if [ "$1" == "-d" ]; then detach="-d"; shift; fi
|
if [ "$1" == "-d" ]; then detach="-d"; shift; fi
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm $detach \
|
--rm $detach \
|
||||||
diaspora \
|
diaspora \
|
||||||
bin/cucumber "$@"
|
bin/cucumber "$@"
|
||||||
|
|
@ -296,21 +306,21 @@ dia_exec() {
|
||||||
if [ "$1" == "-d" ]; then detach="-d"; shift; fi
|
if [ "$1" == "-d" ]; then detach="-d"; shift; fi
|
||||||
if dia_is_running; then
|
if dia_is_running; then
|
||||||
# Use a running container
|
# Use a running container
|
||||||
docker-compose exec $detach diaspora /exec-entrypoint.sh "$@"
|
dia_docker_compose exec $detach diaspora /exec-entrypoint.sh "$@"
|
||||||
else
|
else
|
||||||
if ! dia_is_db_running; then not_running=1; fi
|
if ! dia_is_db_running; then not_running=1; fi
|
||||||
# Start a new container
|
# Start a new container
|
||||||
echo "No running instance found, starting new one for command execution ..."
|
echo "No running instance found, starting new one for command execution ..."
|
||||||
docker-compose run --rm $detach --service-ports diaspora "$@"
|
dia_docker_compose run --rm $detach --service-ports diaspora "$@"
|
||||||
if [ ! -z $not_running ]; then
|
if [ ! -z $not_running ]; then
|
||||||
docker-compose stop $DIASPORA_DOCKER_DB
|
dia_docker_compose stop $DIASPORA_DOCKER_DB
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_jasmine() {
|
dia_jasmine() {
|
||||||
# Run jasmine tests
|
# Run jasmine tests
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm $1 \
|
--rm $1 \
|
||||||
-e RAILS_ENV=test \
|
-e RAILS_ENV=test \
|
||||||
diaspora \
|
diaspora \
|
||||||
|
|
@ -327,14 +337,14 @@ dia_logs() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
docker-compose logs -f --tail=100 $dia_follow
|
dia_docker_compose logs -f --tail=100 $dia_follow
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_migrate() {
|
dia_migrate() {
|
||||||
# Run migrations if configured
|
# Run migrations if configured
|
||||||
echo "Creating and/or migrating database ..."
|
echo "Creating and/or migrating database ..."
|
||||||
exit_if_unconfigured
|
exit_if_unconfigured
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm $1 \
|
--rm $1 \
|
||||||
diaspora \
|
diaspora \
|
||||||
bin/rake db:create db:migrate
|
bin/rake db:create db:migrate
|
||||||
|
|
@ -348,7 +358,7 @@ dia_pronto() {
|
||||||
dia_fetch_upstream
|
dia_fetch_upstream
|
||||||
fi
|
fi
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm \
|
--rm \
|
||||||
--no-deps \
|
--no-deps \
|
||||||
diaspora \
|
diaspora \
|
||||||
|
|
@ -366,11 +376,11 @@ dia_restart() {
|
||||||
done
|
done
|
||||||
if dia_is_running; then
|
if dia_is_running; then
|
||||||
if [ -z $dia_restart_full ]; then
|
if [ -z $dia_restart_full ]; then
|
||||||
docker-compose exec \
|
dia_docker_compose exec \
|
||||||
diaspora \
|
diaspora \
|
||||||
bin/eye restart diaspora
|
bin/eye restart diaspora
|
||||||
else
|
else
|
||||||
docker-compose restart
|
dia_docker_compose restart
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
dia_start
|
dia_start
|
||||||
|
|
@ -384,19 +394,20 @@ dia_rspec() {
|
||||||
# Assumption: If (and only if) the tested file is not available, assets need be regenerated
|
# Assumption: If (and only if) the tested file is not available, assets need be regenerated
|
||||||
[ -f "$DIASPORA_ROOT"/public/404.html ] && assets="assets:generate_error_pages"
|
[ -f "$DIASPORA_ROOT"/public/404.html ] && assets="assets:generate_error_pages"
|
||||||
# Prepare database (and assets if necessary)
|
# Prepare database (and assets if necessary)
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm \
|
--rm \
|
||||||
-e RAILS_ENV=test \
|
-e RAILS_ENV=test \
|
||||||
diaspora \
|
diaspora \
|
||||||
bin/rake db:create db:migrate $assets
|
bin/rake db:create db:migrate $assets
|
||||||
# Run tests
|
# Run tests
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm \
|
--rm \
|
||||||
diaspora \
|
diaspora \
|
||||||
bin/rspec "$@"
|
bin/rspec "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_setup() {
|
dia_setup() {
|
||||||
|
# Prepare the entire environment for development
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
--force)
|
--force)
|
||||||
|
|
@ -408,7 +419,6 @@ dia_setup() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
# Prepare the entire environment for development
|
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
dia_build $build
|
dia_build $build
|
||||||
|
|
@ -418,15 +428,15 @@ dia_setup() {
|
||||||
dia_setup_tests $setup_tests
|
dia_setup_tests $setup_tests
|
||||||
)
|
)
|
||||||
# stop db afterwards as it is not needed while dia is not running
|
# stop db afterwards as it is not needed while dia is not running
|
||||||
docker-compose stop $DIASPORA_DOCKER_DB
|
dia_docker_compose stop $DIASPORA_DOCKER_DB
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_setup_tests() {
|
dia_setup_tests() {
|
||||||
# Prepare all possible tests
|
# Prepare all possible tests
|
||||||
# stop db if it was not running before
|
# stop db if it was not running before
|
||||||
echo "Setting up environment for tests ..."
|
echo "Setting up environment for tests ..."
|
||||||
if ! dia_is_db_running; then stopdb="docker-compose stop $DIASPORA_DOCKER_DB"; fi
|
if ! dia_is_db_running; then stopdb="dia_docker_compose stop $DIASPORA_DOCKER_DB"; fi
|
||||||
docker-compose run \
|
dia_docker_compose run \
|
||||||
--rm \
|
--rm \
|
||||||
-e RAILS_ENV=test \
|
-e RAILS_ENV=test \
|
||||||
diaspora \
|
diaspora \
|
||||||
|
|
@ -442,19 +452,19 @@ dia_start() {
|
||||||
else
|
else
|
||||||
options=$1
|
options=$1
|
||||||
fi
|
fi
|
||||||
docker-compose up $options diaspora
|
dia_docker_compose up $options diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_status() {
|
dia_status() {
|
||||||
# Print running containers and current images
|
# Print running containers and current images
|
||||||
docker-compose ps
|
dia_docker_compose ps
|
||||||
echo
|
echo
|
||||||
docker-compose images
|
dia_docker_compose images
|
||||||
}
|
}
|
||||||
|
|
||||||
dia_stop() {
|
dia_stop() {
|
||||||
# Stop all containers
|
# Stop all containers
|
||||||
docker-compose stop
|
dia_docker_compose stop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue