diff --git a/bin/setup b/bin/setup index 90700ac4f..8a932eeb2 100755 --- a/bin/setup +++ b/bin/setup @@ -15,15 +15,20 @@ FileUtils.chdir APP_ROOT do puts '== Installing dependencies ==' system! 'gem install bundler --conservative' + system!('script/configure_bundler') system('bundle check') || system!('bundle install') # Install JavaScript dependencies system! 'bin/yarn' - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' - # end + unless File.exist?('config/diaspora.toml') + puts "\n== Copying example diaspora.toml ==" + FileUtils.cp 'config/diaspora.toml.example', 'config/database.yml' + end + unless File.exist?('config/database.yml') + puts "\n== Copying example database.yml ==" + FileUtils.cp 'config/database.yml.example', 'config/database.yml' + end puts "\n== Preparing database ==" system! 'bin/rails db:prepare' @@ -31,6 +36,6 @@ FileUtils.chdir APP_ROOT do puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' - puts "\n== Restarting application server ==" - system! 'bin/rails restart' + # puts "\n== Restarting application server ==" + # system! 'bin/rails restart' end diff --git a/docker/develop/Dockerfile b/docker/develop/Dockerfile index e5708eb13..6f9db164c 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7-slim-buster +FROM ruby:2.7-slim-bullseye RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && \ @@ -12,7 +12,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ libcurl4-openssl-dev \ libidn11-dev \ libmagickwand-dev \ - libmariadbclient-dev \ + libmariadb-dev-compat \ libpq-dev \ libssl-dev \ libxml2-dev \ diff --git a/script/diaspora-dev b/script/diaspora-dev index e625524fe..067f8c978 100755 --- a/script/diaspora-dev +++ b/script/diaspora-dev @@ -78,8 +78,11 @@ print_usage() { ;; bundle) echo; echo "Install gems using bundle into $DIASPORA_ROOT" - print_usage_header "bundle [options]" \ - "-d Run in background" + print_usage_header "bundle" + ;; + yarn) + echo; echo "Install frontend dependencies using yarn into $DIASPORA_ROOT" + print_usage_header "yarn" ;; config) echo; echo "Create basic configuration files for usage with PostgreSQL (default)" @@ -98,6 +101,10 @@ print_usage() { echo; echo "Show help on a command" print_usage_header "help COMMAND" ;; + setup-rails) + echo; echo "Set up development environment (install dependencies, migrate db, ...)" + print_usage_header "setup-rails" + ;; setup-tests) echo; echo "Prepare cached files and database contents for tests" print_usage_header "setup-tests" @@ -147,9 +154,11 @@ print_usage_full() { echo "Misc. Commands:" echo " build Build basic diaspora* environment" echo " bundle (Re-)Install gems for diaspora*" + echo " yarn (Re-)Install frontend dependencies for diaspora*" echo " config Configure diaspora*" echo " exec Execute a command in the run environment (advanced)" echo " help Show help for commands" + echo " setup-rails Prepare diaspora* development environment (install dependencies, migrate db)" echo " setup-tests Prepare diaspora* test environment" echo echo "Run '$SCRIPT_NAME help COMMAND' for more information on a command." @@ -218,12 +227,19 @@ dia_bundle() { echo "Installing gems via bundler ..." dia_docker_compose run \ --rm \ - --no-deps $1 \ + --no-deps \ -e DIA_NODB=1 \ diaspora \ /bin/sh -c "gem install bundler && script/configure_bundler && bin/bundle install --full-index" } +dia_yarn() { + # Run yarn in order to install all frontend dependencies into $DIASPORA_ROOT + # Do not start database, not required and sometimes not yet configured + echo "Installing frontend dependencies via yarn ..." + dia_docker_compose run --rm --no-deps -e DIA_NODB=1 diaspora bin/yarn +} + dia_clean() { # Delete all containers and volumes for i in "$@"; do @@ -423,14 +439,23 @@ dia_setup() { set -e dia_build $build dia_config $config - dia_bundle $bundle - dia_migrate $migrate - dia_setup_tests $setup_tests + dia_bundle + dia_setup_rails + dia_setup_tests ) # stop db afterwards as it is not needed while dia is not running dia_docker_compose stop $DIASPORA_DOCKER_DB } +dia_setup_rails() { + # Prepare rails, install dependencies, migrate database, ... + # stop db if it was not running before + echo "Setting up environment for tests ..." + if ! dia_is_db_running; then stopdb="dia_docker_compose stop $DIASPORA_DOCKER_DB"; fi + dia_docker_compose run --rm diaspora bin/setup + $stopdb +} + dia_setup_tests() { # Prepare all possible tests # stop db if it was not running before @@ -510,7 +535,7 @@ case "$dia_command" in dia_build "$@" ;; bundle) - dia_bundle "$1" + dia_bundle ;; clean) dia_clean "$@" @@ -545,6 +570,9 @@ case "$dia_command" in setup) dia_setup "$@" ;; + setup-rails) + dia_setup_rails + ;; setup-tests) dia_setup_tests ;; @@ -557,6 +585,9 @@ case "$dia_command" in stop) dia_stop ;; + yarn) + dia_yarn + ;; *) print_usage exit 1