diff --git a/Dockerfile b/Dockerfile index 015222ff..192d92c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,11 +30,7 @@ FROM dev_base as test ENV RAILS_ENV=test \ APP_PATH=/exhibits -# Install application gems WORKDIR $APP_PATH -COPY Gemfile Gemfile.lock ./ -RUN bundle install - COPY . . ENTRYPOINT [ "docker/build_test.sh" ] @@ -64,7 +60,7 @@ COPY --chown=${USER}:${GROUP} . . # Run the web server EXPOSE 9292 -ENTRYPOINT [ "docker/puma.sh" ] +ENTRYPOINT [ "docker/run_dev.sh" ] ################################################################################ # Bundle production/integration/staging environment @@ -126,4 +122,4 @@ WORKDIR ${APP_PATH} # Run the web server EXPOSE 9292 -ENTRYPOINT [ "docker/puma.sh" ] +ENTRYPOINT [ "docker/run.sh" ] diff --git a/Gemfile b/Gemfile index d8452939..a7e5005c 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,6 @@ gem 'blacklight-spotlight', '~> 3.5' group :development do gem 'better_errors' # add command line in browser when errors gem 'binding_of_caller' # deeper stack trace used by better errors - gem 'letter_opener' # show emails in browser gem 'listen' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index b2fc5436..cb1358a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -356,8 +356,6 @@ GEM railties (>= 4.2.0) legato (0.7.0) multi_json - letter_opener (1.8.1) - launchy (>= 2.2, < 3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -713,7 +711,6 @@ DEPENDENCIES irb jbuilder (~> 2.5) jquery-rails - letter_opener listen mina mysql2 diff --git a/config/environments/development.rb b/config/environments/development.rb index 848a75de..cccc96a1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -33,7 +33,7 @@ config.active_storage.service = :local # Configure Email Notifications - config.action_mailer.delivery_method = :letter_opener # Open emails in a web browser + config.action_mailer.delivery_method = :test config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_caching = false diff --git a/docker/build_test.sh b/docker/build_test.sh index bc3e63c7..9f7f33de 100755 --- a/docker/build_test.sh +++ b/docker/build_test.sh @@ -2,8 +2,13 @@ set -e -# Prepare DB (Migrate if exists; else Create db & Migrate) -sh ./docker/db_prepare.sh +# Install gems +bundle install -# Run the command defined in compose.test.yaml +# If the database exists, migrate. Otherwise setup (create and migrate) +echo "Preparing Database..." +bundle exec rake db:environment:set RAILS_ENV=test db:migrate 2>/dev/null || bundle exec rake db:environment:set RAILS_ENV=test db:create db:schema:load +echo "Database Migration Done!" + +# Run commands exec "$@" diff --git a/docker/db_prepare.sh b/docker/db_prepare.sh deleted file mode 100755 index f9753036..00000000 --- a/docker/db_prepare.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# If the database exists, migrate. Otherwise setup (create and migrate) -echo "Preparing Database..." -bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:environment:set RAILS_ENV=$RAILS_ENV db:create db:schema:load -echo "Database Migration Done!" diff --git a/docker/puma.sh b/docker/run.sh old mode 100755 new mode 100644 similarity index 77% rename from docker/puma.sh rename to docker/run.sh index 47d8be06..5e39dc83 --- a/docker/puma.sh +++ b/docker/run.sh @@ -16,11 +16,10 @@ then cron fi -# Prepare DB (Migrate if exists; else Create db & Migrate) -sh ./docker/db_prepare.sh - -# Run the command defined in compose.yaml -exec "$@" +# Run db migrations +echo "Preparing Database..." +bundle exec rake db:migrate RAILS_ENV=$RAILS_ENV +echo "Database Migration Done!" # Start sidekiq bundle exec sidekiq -L log/sidekiq.log -e $RAILS_ENV -C config/sidekiq.yml -d @@ -28,3 +27,6 @@ bundle exec sidekiq -L log/sidekiq.log -e $RAILS_ENV -C config/sidekiq.yml -d # Start the web server mkdir -p ./tmp/pids bundle exec puma -C config/puma.rb -e $RAILS_ENV + +# Run commands +exec "$@" diff --git a/docker/run_dev.sh b/docker/run_dev.sh new file mode 100755 index 00000000..1b638697 --- /dev/null +++ b/docker/run_dev.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +# If the database exists, migrate. Otherwise setup (create and migrate) +echo "Preparing Database..." +bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:create db:schema:load +echo "Database Migration Done!" + +# Start sidekiq +bundle exec sidekiq -L log/sidekiq.log -e $RAILS_ENV -C config/sidekiq.yml -d + +# Start the web server +mkdir -p ./tmp/pids +bundle exec puma -C config/puma.rb -e $RAILS_ENV + +# Run commands +exec "$@" diff --git a/docker/run_test.sh b/docker/run_test.sh index bac39bcb..8460fbf8 100755 --- a/docker/run_test.sh +++ b/docker/run_test.sh @@ -9,7 +9,7 @@ done if [ $interactive = true ] then - docker compose -p exhibits-test -f compose.test.yaml run --entrypoint=bash webapp + docker compose -p exhibits-test -f compose.test.yaml run webapp bash else docker compose -p exhibits-test -f compose.test.yaml run webapp bundle exec rspec fi