From 08e6f1e2a3ca7dce60f2e62a7133528f1cd3049f Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Thu, 21 Jul 2022 22:33:02 +0200 Subject: [PATCH 1/4] Configure bundler and copy example configs on bin/setup and also remove `bin/rails restart`, this does nothing for us at the moment anyway, so just remove it. --- bin/setup | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 From 95a9c329af35ab5a780476e0642215f14f017052 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Thu, 21 Jul 2022 22:42:37 +0200 Subject: [PATCH 2/4] Add command for bin/setup to the diaspora-dev docker script and also use it for the initial setup command, so it also install yarn dependencies --- script/diaspora-dev | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/script/diaspora-dev b/script/diaspora-dev index e625524fe..c7ac127c6 100755 --- a/script/diaspora-dev +++ b/script/diaspora-dev @@ -98,6 +98,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" @@ -150,6 +154,7 @@ print_usage_full() { 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." @@ -423,14 +428,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 @@ -545,6 +559,9 @@ case "$dia_command" in setup) dia_setup "$@" ;; + setup-rails) + dia_setup_rails + ;; setup-tests) dia_setup_tests ;; From fdcea3e82406ccb3f0cffb45ad097846dc073ba4 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Thu, 21 Jul 2022 22:44:03 +0200 Subject: [PATCH 3/4] Add yarn command to the diaspora-dev docker script --- script/diaspora-dev | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/script/diaspora-dev b/script/diaspora-dev index c7ac127c6..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)" @@ -151,6 +154,7 @@ 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" @@ -223,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 @@ -524,7 +535,7 @@ case "$dia_command" in dia_build "$@" ;; bundle) - dia_bundle "$1" + dia_bundle ;; clean) dia_clean "$@" @@ -574,6 +585,9 @@ case "$dia_command" in stop) dia_stop ;; + yarn) + dia_yarn + ;; *) print_usage exit 1 From 662635fe35fcc62e97d020af0e963c6afe2381c5 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Thu, 21 Jul 2022 22:56:55 +0200 Subject: [PATCH 4/4] Upgrade development Dockerfile to debian bullseye to have a current version of yarn --- docker/develop/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 \