From 20839f2b9106754fe486994bc85ed24fa07cb92d Mon Sep 17 00:00:00 2001 From: Toby Bellwood Date: Fri, 21 Jun 2024 10:48:10 +1000 Subject: [PATCH] chore: update demo --- .env | 2 + .github/workflows/ruby-example.yaml | 9 +- Gemfile | 8 +- Gemfile.lock | 315 +++++++++++++------------ TESTING_dockercompose.md | 44 ++-- app/controllers/articles_controller.rb | 2 +- docker-compose.yml | 2 +- lagoon/ruby.dockerfile | 4 +- renovate.json | 6 + 9 files changed, 211 insertions(+), 181 deletions(-) create mode 100644 .env create mode 100644 renovate.json diff --git a/.env b/.env new file mode 100644 index 0000000..bdfd03f --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# Local project name - setting this here aligns container names with routes +COMPOSE_PROJECT_NAME=ruby-on-rails diff --git a/.github/workflows/ruby-example.yaml b/.github/workflows/ruby-example.yaml index 6d2beee..8e2e8bb 100644 --- a/.github/workflows/ruby-example.yaml +++ b/.github/workflows/ruby-example.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: "0" - name: install Lando @@ -24,7 +24,6 @@ jobs: - name: Report versions run: | docker version - docker-compose version lando version node -v yarn -v @@ -39,13 +38,13 @@ jobs: groups - name: Pull all images run: | - docker-compose pull --ignore-pull-failures + docker compose pull --ignore-pull-failures - name: Install test harness run: | yarn add leia-parser mocha chai@4 command-line-test - name: Generate test files run: | yarn leia "TESTING*.md" test -r 2 -s 'Start up tests' -t 'Verification commands' -c 'Destroy tests' --split-file - - name: Run docker-compose tests + - name: Run docker compose tests run: | - yarn mocha --timeout 900000 test/*compose*.func.js \ No newline at end of file + yarn mocha --timeout 900000 test/*compose*.func.js diff --git a/Gemfile b/Gemfile index aec123a..eec03a0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,19 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.2" - # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.0.3", ">= 7.0.3.1" +gem "rails" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" # Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" +gem "sqlite3" gem "pg" # Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" +gem "puma" # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] gem "importmap-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 024e386..55d155c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,218 +1,246 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.3.1) - actionpack (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.3.1) - actionview (= 7.0.3.1) - activesupport (= 7.0.3.1) - rack (~> 2.0, >= 2.2.0) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.3.1) - actionpack (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.3.1) - activesupport (= 7.0.3.1) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.3.1) - activesupport (= 7.0.3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.0.3.1) - activesupport (= 7.0.3.1) - activerecord (7.0.3.1) - activemodel (= 7.0.3.1) - activesupport (= 7.0.3.1) - activestorage (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activesupport (= 7.0.3.1) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.3.1) + activesupport (7.1.3.4) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + base64 (0.2.0) + bigdecimal (3.1.8) bindex (0.8.1) - bootsnap (1.12.0) + bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.2.4) - capybara (3.37.1) + builder (3.3.0) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - childprocess (4.1.0) - concurrent-ruby (1.1.10) + concurrent-ruby (1.3.3) + connection_pool (2.4.1) crass (1.0.6) - debug (1.6.0) - irb (>= 1.3.6) - reline (>= 0.3.1) - digest (3.1.0) - erubi (1.10.0) - globalid (1.0.0) - activesupport (>= 5.0) - i18n (1.11.0) + date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + drb (2.2.1) + erubi (1.13.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) - importmap-rails (1.1.2) + importmap-rails (2.0.1) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.5.11) - irb (1.4.1) - reline (>= 0.3.0) - jbuilder (2.11.5) + io-console (0.7.2) + irb (1.13.2) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) + logger (1.6.0) logstash-event (1.2.02) logstash-logger (0.26.1) logstash-event (~> 1.2) - loofah (2.18.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.16.2) - msgpack (1.5.3) - net-imap (0.2.3) - digest - net-protocol - strscan - net-pop (0.1.1) - digest + mini_mime (1.1.5) + minitest (5.24.0) + msgpack (1.7.2) + mutex_m (0.2.0) + net-imap (0.4.13) + date net-protocol + net-pop (0.1.2) + net-protocol (0.2.2) timeout - net-protocol (0.1.3) - timeout - net-smtp (0.3.1) - digest + net-smtp (0.5.0) net-protocol - timeout - nio4r (2.5.8) - nokogiri (1.13.7-x86_64-linux) + nio4r (2.7.3) + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) - pg (1.4.1) - public_suffix (4.0.7) - puma (5.6.4) + pg (1.5.6) + psych (5.1.2) + stringio + public_suffix (5.1.1) + puma (6.4.2) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) - rack-test (2.0.2) + racc (1.8.0) + rack (3.1.3) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) rack (>= 1.3) - rails (7.0.3.1) - actioncable (= 7.0.3.1) - actionmailbox (= 7.0.3.1) - actionmailer (= 7.0.3.1) - actionpack (= 7.0.3.1) - actiontext (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activemodel (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.0.3.1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.1.3.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - railties (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) - method_source + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rake (13.0.6) - regexp_parser (2.5.0) - reline (0.3.1) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.9) io-console (~> 0.5) - rexml (3.2.5) + rexml (3.3.0) + strscan rubyzip (2.3.2) - selenium-webdriver (4.3.0) - childprocess (>= 0.5, < 5.0) + selenium-webdriver (4.22.0) + base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sprockets (4.1.1) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - sqlite3 (1.4.4) - stimulus-rails (1.0.4) + sqlite3 (2.0.2-x86_64-linux-musl) + stimulus-rails (1.3.3) railties (>= 6.0.0) - strscan (3.0.3) - thor (1.2.1) - timeout (0.3.0) - turbo-rails (1.1.1) + stringio (3.1.1) + strscan (3.1.0) + thor (1.3.1) + timeout (0.4.1) + turbo-rails (2.0.5) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) - tzinfo (2.0.4) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.0.0) + webdrivers (5.2.0) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) - websocket (1.2.9) - websocket-driver (0.7.5) + webrick (1.8.1) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.0) + zeitwerk (2.6.16) PLATFORMS x86_64-linux-musl @@ -225,19 +253,16 @@ DEPENDENCIES jbuilder logstash-logger pg - puma (~> 5.0) - rails (~> 7.0.3, >= 7.0.3.1) + puma + rails selenium-webdriver sprockets-rails - sqlite3 (~> 1.4) + sqlite3 stimulus-rails turbo-rails tzinfo-data web-console webdrivers -RUBY VERSION - ruby 3.1.2p20 - BUNDLED WITH 2.3.17 diff --git a/TESTING_dockercompose.md b/TESTING_dockercompose.md index 64d4bdc..9decd03 100644 --- a/TESTING_dockercompose.md +++ b/TESTING_dockercompose.md @@ -1,7 +1,7 @@ Docker Compose Ruby on Rails - ruby3.1, nginx, postgres ======================================================== -This is a docker-compose version of the Lando example tests: +This is a docker compose version of the Lando example tests: Start up tests -------------- @@ -11,10 +11,10 @@ Run the following commands to get up and running with this example. ```bash # Should remove any previous runs and poweroff docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network -docker-compose down +docker compose down # Should start up our Lagoon ruby on rails site successfully -docker-compose build && docker-compose up -d +docker compose build && docker compose up -d # Ensure postgres pod is ready to connect, then sleep for 60s docker run --rm --net ruby-on-rails_default amazeeio/dockerize dockerize -wait tcp://postgres:5432 -timeout 1m @@ -28,43 +28,43 @@ Run the following commands to validate things are rolling as they should. ```bash # Should set the Rails ENV -docker-compose exec -T ruby sh -c "rails db:migrate RAILS_ENV=development" +docker compose exec -T ruby sh -c "rails db:migrate RAILS_ENV=development" # Should have all the services we expect -docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails_nginx_1 -docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails_postgres_1 -docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails_ruby_1 +docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails-nginx-1 +docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails-postgres-1 +docker ps --filter label=com.docker.compose.project=ruby-on-rails | grep Up | grep ruby-on-rails-ruby-1 # Should ssh against the ruby container by default -docker-compose exec -T ruby sh -c "env | grep LAGOON=" | grep ruby +docker compose exec -T ruby sh -c "env | grep LAGOON=" | grep ruby # Should have the correct environment set -docker-compose exec -T ruby sh -c "env" | grep LAGOON_ROUTE | grep ruby.docker.amazee.io +docker compose exec -T ruby sh -c "env" | grep LAGOON_ROUTE | grep ruby-on-rails.docker.amazee.io # Should be running Ruby 3 -docker-compose exec -T ruby sh -c "ruby -v" | grep "ruby 3" +docker compose exec -T ruby sh -c "ruby -v" | grep "ruby 3" # Should have Puma -docker-compose exec -T ruby sh -c "puma --version" +docker compose exec -T ruby sh -c "puma --version" # Should have gems - ruby & puma -docker-compose exec -T ruby sh -c "gem list -i puma | gem list -i ruby" +docker compose exec -T ruby sh -c "gem list -i puma | gem list -i ruby" # Should have a running site served by nginx on port 8080 -docker-compose exec -T ruby sh -c "curl -kL http://nginx:8080" | grep "Articles" +docker compose exec -T ruby sh -c "curl -kL http://nginx:8080" | grep "Articles" # Should be able to db-export and db-import the database -docker-compose exec -T ruby sh -c "rails db:schema:dump" # Creates a database schema file db/schema.rb -docker-compose exec -T ruby sh -c "rails db:drop" -docker-compose exec -T ruby sh -c "rails db:create" -docker-compose exec -T ruby sh -c "rails db:schema:load" # Loads a database schema file db/schema.rb +docker compose exec -T ruby sh -c "rails db:schema:dump" # Creates a database schema file db/schema.rb +docker compose exec -T ruby sh -c "rails db:drop" +docker compose exec -T ruby sh -c "rails db:create" +docker compose exec -T ruby sh -c "rails db:schema:load" # Loads a database schema file db/schema.rb # Should be able to show the 'articles' tables -docker-compose exec -T ruby sh -c "echo QWN0aXZlUmVjb3JkOjpCYXNlLmNvbm5lY3Rpb24udGFibGVfZXhpc3RzPyAnYXJ0aWNsZXMnCg== | base64 -d | rails console" +docker compose exec -T ruby sh -c "echo QWN0aXZlUmVjb3JkOjpCYXNlLmNvbm5lY3Rpb24udGFibGVfZXhpc3RzPyAnYXJ0aWNsZXMnCg== | base64 -d | rails console" # Should be able to rebuild and persist the database -docker-compose build && docker-compose up -d -docker-compose exec -T ruby sh -c "echo QWN0aXZlUmVjb3JkOjpCYXNlLmNvbm5lY3Rpb24udGFibGVfZXhpc3RzPyAnYXJ0aWNsZXMnCg== | base64 -d | rails console" +docker compose build && docker compose up -d +docker compose exec -T ruby sh -c "echo QWN0aXZlUmVjb3JkOjpCYXNlLmNvbm5lY3Rpb24udGFibGVfZXhpc3RzPyAnYXJ0aWNsZXMnCg== | base64 -d | rails console" ``` Destroy tests @@ -74,5 +74,5 @@ Run the following commands to trash this app like nothing ever happened. ```bash # Should be able to destroy our rails site with success -docker-compose down --volumes --remove-orphans -``` \ No newline at end of file +docker compose down --volumes --remove-orphans +``` diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index a26141d..fb8f39b 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -1,5 +1,5 @@ class ArticlesController < ApplicationController - + skip_before_action :verify_authenticity_token, only: [:create, :update] http_basic_authenticate_with name: "dhh", password: "secret", except: [:index, :show] def index diff --git a/docker-compose.yml b/docker-compose.yml index 9c0decf..3a04192 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -63,7 +63,7 @@ services: - default postgres: - image: uselagoon/postgres-11-drupal:latest + image: uselagoon/postgres-15-drupal:latest labels: lagoon.type: postgres lando.type: postgres-drupal diff --git a/lagoon/ruby.dockerfile b/lagoon/ruby.dockerfile index 524e74a..fa51e49 100644 --- a/lagoon/ruby.dockerfile +++ b/lagoon/ruby.dockerfile @@ -1,4 +1,4 @@ -FROM testlagoon/ruby-3.1:experimental +FROM uselagoon/ruby-3.3:latest ENV LAGOON=ruby @@ -17,4 +17,4 @@ RUN bundle install EXPOSE 3000 -CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] \ No newline at end of file +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..6f008aa --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] + }