From 4f9b05f6fc98044370f2f5cb2e2eb8c9186a16b7 Mon Sep 17 00:00:00 2001 From: iberianpig Date: Thu, 13 Feb 2025 08:29:34 +0900 Subject: [PATCH 1/2] feat: use nodesource for Node.js installation Replaced snap installation with nodesource setup for Node.js. For WSL (Windows Subsystem for Linux) and Docker environments, it is recommended to use the NodeSource repository when installing Node.js because it is difficult to run `snapd` with `systemd`. This method allows you to easily install and manage the latest version of Node.js. https://github.com/nodesource/distributions?tab=readme-ov-file#installation-instructions-deb --- rails-install-ubuntu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rails-install-ubuntu.sh b/rails-install-ubuntu.sh index 7a105f2..1283066 100644 --- a/rails-install-ubuntu.sh +++ b/rails-install-ubuntu.sh @@ -16,8 +16,8 @@ echo "Install packages. Enter your password when asked." sudo apt-get --ignore-missing install build-essential git-core curl openssl libssl-dev libcurl4-openssl-dev zlib1g zlib1g-dev libreadline6-dev libyaml-dev libsqlite3-dev libsqlite3-0 sqlite3 libxml2-dev libxslt1-dev libffi-dev software-properties-common libgdm-dev libncurses5-dev automake autoconf libtool bison postgresql postgresql-contrib libpq-dev libc6-dev -y echo "Install Node.js" -sudo apt-get install -y snapd -sudo snap install node --classic --channel=18 +curl -fsSL https://deb.nodesource.com/setup_23.x | sudo bash - +sudo apt-get install -y nodejs echo "Install ImageMagick for image processing" sudo apt-get install imagemagick --fix-missing -y From 58cd99d57b63a121e07448a669be105b9ee51669 Mon Sep 17 00:00:00 2001 From: iberianpig Date: Thu, 13 Feb 2025 09:10:52 +0900 Subject: [PATCH 2/2] feat: Use Ruby 3.4.1 and Rails 8.0.1 in Ubuntu 24.04 - Update Ruby version to 3.4.1 - Update Rails version to 8.0.1 ```dockerfile FROM ubuntu:24.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y sudo tzdata RUN echo 'ubuntu:ubuntu' |chpasswd USER ubuntu ``` in local terminal ``` $ docker build -t my_ubuntu:24.04 ./Dockerfile $ docker run -it --rm -v ${PWD}:/home/ubuntu/installation-scripts my_ubuntu:24.04 ``` in Docker container ``` ubuntu@ed8da7560cd8:~$ bash < <(cat ~/installation-scripts/rails-install-ubuntu.sh) ubuntu@ed8da7560cd8:~$ source ~/.profile ubuntu@ed8da7560cd8:~$ ruby -v ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] ubuntu@ed8da7560cd8:~$ rails -v Rails 8.0.1 ubuntu@ed8da7560cd8:~$ ubuntu@ed8da7560cd8:~$ rails new .bash_logout .cache/ .local/ .rbenv/ installation-scripts/ .bashrc .gemrc .profile .sudo_as_admin_successful ubuntu@ed8da7560cd8:~$ pwd /home/ubuntu ubuntu@ed8da7560cd8:~$ rails new my_app create create README.md create Rakefile create .ruby-version create config.ru create .gitignore create .gitattributes create Gemfile run git init -b main from "." Initialized empty Git repository in /home/ubuntu/my_app/.git/ create app create app/assets/stylesheets/application.css create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/jobs/application_job.rb create app/mailers/application_mailer.rb create app/models/application_record.rb create app/views/layouts/application.html.erb create app/views/layouts/mailer.html.erb create app/views/layouts/mailer.text.erb create app/views/pwa/manifest.json.erb create app/views/pwa/service-worker.js create app/assets/images create app/assets/images/.keep create app/controllers/concerns/.keep create app/models/concerns/.keep create bin create bin/brakeman create bin/dev create bin/rails create bin/rake create bin/rubocop create bin/setup create bin/thrust create Dockerfile create .dockerignore create bin/docker-entrypoint create .rubocop.yml create .github/workflows create .github/workflows/ci.yml create .github/dependabot.yml create config create config/routes.rb create config/application.rb create config/environment.rb create config/cable.yml create config/puma.rb create config/storage.yml create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/assets.rb create config/initializers/content_security_policy.rb create config/initializers/cors.rb create config/initializers/filter_parameter_logging.rb create config/initializers/inflections.rb create config/initializers/new_framework_defaults_8_0.rb create config/locales create config/locales/en.yml create config/master.key append .gitignore create config/boot.rb create config/database.yml create db create db/seeds.rb create lib create lib/tasks create lib/tasks/.keep create log create log/.keep create public create public/400.html create public/404.html create public/406-unsupported-browser.html create public/422.html create public/500.html create public/icon.png create public/icon.svg create public/robots.txt create script create script/.keep create tmp create tmp/.keep create tmp/pids create tmp/pids/.keep create vendor create vendor/.keep create test/fixtures/files create test/fixtures/files/.keep create test/controllers create test/controllers/.keep create test/mailers create test/mailers/.keep create test/models create test/models/.keep create test/helpers create test/helpers/.keep create test/integration create test/integration/.keep create test/test_helper.rb create test/system create test/system/.keep create test/application_system_test_case.rb create storage create storage/.keep create tmp/storage create tmp/storage/.keep remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_8_0.rb run bundle install --quiet run bundle lock --add-platform=x86_64-linux Writing lockfile to /home/ubuntu/my_app/Gemfile.lock Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... run bundle binstubs bundler rails importmap:install apply /home/ubuntu/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/importmap-rails-2.1.0/lib/install/install.rb Add Importmap include tags in application layout insert app/views/layouts/application.html.erb Create application.js module as entrypoint create app/javascript/application.js Use vendor/javascript for downloaded pins create vendor/javascript create vendor/javascript/.keep Configure importmap paths in config/importmap.rb create config/importmap.rb Copying binstub create bin/importmap run bundle install --quiet rails turbo:install stimulus:install apply /home/ubuntu/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/turbo-rails-2.0.11/lib/install/turbo_with_importmap.rb Import Turbo append app/javascript/application.js Pin Turbo append config/importmap.rb run bundle install --quiet apply /home/ubuntu/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/stimulus-rails-1.3.4/lib/install/stimulus_with_importmap.rb Create controllers directory create app/javascript/controllers create app/javascript/controllers/index.js create app/javascript/controllers/application.js create app/javascript/controllers/hello_controller.js Import Stimulus controllers append app/javascript/application.js Pin Stimulus Appending: pin "@hotwired/stimulus", to: "stimulus.min.js" append config/importmap.rb Appending: pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" append config/importmap.rb Pin all controllers Appending: pin_all_from "app/javascript/controllers", under: "controllers" append config/importmap.rb run bundle install --quiet run bundle binstubs kamal run bundle exec kamal init Created configuration file in config/deploy.yml Created .kamal/secrets file Created sample hooks in .kamal/hooks force .kamal/secrets force config/deploy.yml rails solid_cache:install solid_queue:install solid_cable:install create config/cache.yml create db/cache_schema.rb gsub config/environments/production.rb create config/queue.yml create config/recurring.yml create db/queue_schema.rb create bin/jobs gsub config/environments/production.rb create db/cable_schema.rb force config/cable.yml ubuntu@ed8da7560cd8:~$ cd my_app/ ubuntu@ed8da7560cd8:~/my_app$ rails s => Booting Puma => Rails 8.0.1 application starting in development => Run `bin/rails server --help` for more startup options Puma starting in single mode... * Puma version: 6.6.0 ("Return to Forever") * Ruby version: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Min threads: 3 * Max threads: 3 * Environment: development * PID: 25666 * Listening on http://127.0.0.1:3000 * Listening on http://[::1]:3000 Use Ctrl-C to stop ``` --- README.md | 1 + rails-install-ubuntu.sh | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b8bd509..448f1a2 100644 --- a/README.md +++ b/README.md @@ -10,5 +10,6 @@ To install Ruby on Rails development environment, copy and paste this line in th sudo apt-get install curl bash <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-ubuntu.sh) + source ~/.profile diff --git a/rails-install-ubuntu.sh b/rails-install-ubuntu.sh index 1283066..d6e3115 100644 --- a/rails-install-ubuntu.sh +++ b/rails-install-ubuntu.sh @@ -45,7 +45,7 @@ echo "Load rbenv config in install script" eval "$($HOME/.rbenv/bin/rbenv init - bash)" echo "Install Ruby" -RUBY_VERSION=3.1.3 +RUBY_VERSION=3.4.1 rbenv install "$RUBY_VERSION" rbenv global "$RUBY_VERSION" @@ -56,11 +56,11 @@ gem install bundler rails echo -e "\n- - - - - -\n" echo -e "Now we are going to print some information to check that everything is done:\n" -echo -n "Should be SQLite 3.22.0 or higher: sqlite " +echo -n "Should be SQLite 3.45.1 or higher: sqlite " sqlite3 --version -echo -n "Should be Ruby 3.1.3 or higher: " +echo -n "Should be Ruby $RUBY_VERSION or higher: " ruby -v | cut -d " " -f 2 -echo -n "Should be Rails 7.0 or higher: " +echo -n "Should be Rails 8.0 or higher: " rails -v echo -e "\n- - - - - -\n"