diff --git a/README.md b/README.md index c79816b..60febc3 100644 --- a/README.md +++ b/README.md @@ -185,24 +185,26 @@ bin/setup You will see something like that: ``` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Rails 7. StartKit -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What was done: 1. Pull all required Images 2. Launching ElasticSearch Container -3. Launching PgSQL Container -4. Launching Redis Container -5. Launching Rails Container -6. Installing Gems. Please Wait -7. Create DB. Migrate DB. Create Seeds -8. Indexing Article Model -9. Launching Rails App with Puma -10. Launching Sidekiq -11. Visit: http://localhost:3000 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +3. Launching Mailcatcher Container +4. Launching PgSQL Container +5. Launching Redis Container +6. Launching Rails Container +7. Installing Gems. Please Wait +8. Create DB. Migrate DB. Create Seeds +9. Indexing Article Model +10. Launching Rails App with Puma +11. Launching Sidekiq +12. Visit Rails App: http://localhost:3000 +13. Visit Mail Service: http://localhost:1080 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Welcome to RAILS 7! -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
diff --git a/app/mailers/demo_mailer.rb b/app/mailers/demo_mailer.rb new file mode 100644 index 0000000..b089f7a --- /dev/null +++ b/app/mailers/demo_mailer.rb @@ -0,0 +1,13 @@ +# rails generate mailer demo +# +# DemoMailer.welcome_email.deliver! +class DemoMailer < ApplicationMailer + default from: 'demo@rails7startkit.com' + + def welcome_email + mail( + to: "test@test.com", + subject: 'Welcome to Rails 7. StartKit' + ) + end +end diff --git a/app/views/demo_mailer/welcome_email.html.erb b/app/views/demo_mailer/welcome_email.html.erb new file mode 100644 index 0000000..22854cd --- /dev/null +++ b/app/views/demo_mailer/welcome_email.html.erb @@ -0,0 +1,10 @@ + + + + + + +

Welcome to Rails7. StartKit

+

Thanks for using this project!

+ + diff --git a/bin/open b/bin/open index ebb6620..64b8ef2 100755 --- a/bin/open +++ b/bin/open @@ -7,7 +7,8 @@ CONTAINER_SHELL_MAP = { rails: :bash, psql: :bash, redis: :ash, - elastic: :bash + elastic: :bash, + mailcatcher: :ash } unless CONTAINER_SHELL_MAP.key?(container_name) diff --git a/bin/setup b/bin/setup index 7f1389f..f8a1a65 100755 --- a/bin/setup +++ b/bin/setup @@ -16,7 +16,12 @@ FileUtils.chdir APP_ROOT do # ElasticSearch step_info "Launching ElasticSearch Container" system('docker compose -f docker/docker-compose.yml up elastic -d') - wait('to launch ElasticSearch Container', 5) + wait('to launch ElasticSearch Container') + + # Mailcatcher + step_info "Launching Mailcatcher Container" + system('docker compose -f docker/docker-compose.yml up mailcatcher -d') + wait('to launch Mailcatcher Container') # PgSQL FileUtils.rm('db/PGSQL/.keep', force: true) @@ -50,7 +55,8 @@ FileUtils.chdir APP_ROOT do step_info "Launching Sidekiq" sidekiq_start - step_info "Visit: http://localhost:3000" + step_info "Visit Rails App: http://localhost:3000" + step_info "Visit Mail Service: http://localhost:1080" containers_information diff --git a/config/environments/development.rb b/config/environments/development.rb index ec3183e..901add9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -48,6 +48,12 @@ config.active_storage.service = :local # Don't care if the mailer can't send. + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: "mailcatcher", + port: 1025 + } + config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false diff --git a/docker/Dockerfile b/docker/Dockerfile index 0778b13..e69031d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,6 +27,7 @@ RUN apt-get update && apt-get install --yes \ SHELL ["/bin/bash", "--login", "-c"] +# TODO: gem update --system 3.4.5 RUN gem update --system 3.4.2 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4502ffe..043622a 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -51,6 +51,14 @@ services: - ../log/ELASTIC:/usr/share/elasticsearch/logs - ../shared:/shared + # port 1080 + # + # mailcatcher does not start with ruby 3.2 + mailcatcher: + image: schickling/mailcatcher + ports: + - 1080:1080 + # port 3000 # rails: diff --git a/test/mailers/demo_mailer_test.rb b/test/mailers/demo_mailer_test.rb new file mode 100644 index 0000000..d862ef3 --- /dev/null +++ b/test/mailers/demo_mailer_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class DemoMailerTest < ActionMailer::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/mailers/previews/demo_mailer_preview.rb b/test/mailers/previews/demo_mailer_preview.rb new file mode 100644 index 0000000..fb44f20 --- /dev/null +++ b/test/mailers/previews/demo_mailer_preview.rb @@ -0,0 +1,7 @@ +# Preview all emails at http://localhost:3000/rails/mailers/demo_mailer +class DemoMailerPreview < ActionMailer::Preview + # Accessible from http://localhost:3000/rails/mailers/demo_mailer/welcome_email + def welcome_email + DemoMailer.welcome_email + end +end