From 50cadfabeb265684da89b10cc7698f5bfd7ca704 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Wed, 30 Nov 2022 18:44:14 -0800 Subject: [PATCH 1/3] Update Vagrantfile --- Vagrantfile | 75 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2a4476d..3adecb1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,28 +5,45 @@ # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. +# +# Use `apt-get`, not `apt`, in these commands to avoid warnings. +# Vagrant.configure("2") do |config| - if ARGV[1] == "clean-focal" - config.vm.define "clean-focal" do |clean| + if ARGV[1] == "clean-jammy" + config.vm.define "clean-jammy" do |clean| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. - config.vm.box = "ubuntu/focal64" + config.vm.box = "ubuntu/jammy64" clean.vm.provider "virtualbox" do |vb| # Use VBoxManage to customize the VM. For example to change memory: vb.customize ["modifyvm", :id, "--memory", "2048"] + # Open the gui for debugging, while updating this Vagrantfile + # vb.gui="true" end clean.vm.network "forwarded_port", guest: 3000, host: 3000 - clean.vm.provision :shell, inline: <<-SHELL + # Silence warnings "dpkg-preconfigure: unable to re-open stdin" + # Must come before any `apt-get` calls + config.vm.provision :shell, inline: <<-SHELL update-locale LANG=en_US.UTF-8 - apt-get -y update - DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade + export DEBIAN_FRONTEND=noninteractive + SHELL + + # Update repositories + config.vm.provision :shell, inline: "apt-get -y update" + + # Upgrade installed packages + config.vm.provision :shell, inline: "apt-get upgrade -y" + + # Add Debian and MySQL server + clean.vm.provision :shell, inline: <<-SHELL + apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' apt-get -y install mysql-server @@ -35,26 +52,56 @@ Vagrant.configure("2") do |config| ln -fs /vagrant/mo-dev /usr/local/bin/mo-dev apt-get -y install git build-essential wget curl vim ruby \ imagemagick libmagickcore-dev libmagickwand-dev libjpeg-dev \ - libgmp3-dev gnupg2 + libgmp3-dev SHELL + # Add public key for rvm and install rvm. clean.vm.provision :shell, privileged: false, inline: <<-SHELL - gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - curl -L https://get.rvm.io | bash -s stable + # Note: rvm's listed keyservers (incl. MIT.edu) are extremely + # unreliable. Hours of inexplicable failure to find the public keys. + # Pro tip - do not use keyservers at all! Grrrrrrrrrr. - AN 11/2022 + # These may be less secure than keyservers, but at least they load. + curl -sSL https://rvm.io/mpapis.asc | gpg --import - + curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - + # Trust them keys + echo 409B6B1796C275462A1703113804BB82D39DC0E3:6: | gpg --import-ownertrust # mpapis@gmail.com + echo 7D2BAF1CF37B13E2069D6956105BD0E739499BDB:6: | gpg --import-ownertrust # piotr.kuczynski@gmail.com + + curl -sSL https://get.rvm.io | bash -s stable source ~/.rvm/scripts/rvm - rvm install 2.7.6 + + rvm use --default --install 3.1.2 + # gem install bundler + # gem install railties + rvm cleanup all SHELL + # # Add Google Chrome repository and install + # config.vm.provision :shell, inline: <<-SHELL + # wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub|sudo apt-key add - + # sudo sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" > /etc/apt/sources.list.d/google.list' + # # Add Google Chrome for selenium tests + # sudo apt install -y google-chrome-stable + + # # This simpler way didn't work: + # # wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/ + # # dpkg -i ~/google-chrome*.deb" + # # apt-get install -f -y" + # SHELL + + # Add Firefox for selenium. Slow: Do this last in case troubleshooting. + config.vm.provision :shell, inline: "apt-get install -y firefox" + clean.trigger.after [:provision] do |t| t.name = "Reboot after provisioning" t.run = { :inline => "vagrant reload clean" } end end else - version_date = "2022-06-04" - config.vm.define "mo-focal-#{version_date}", primary: true do |mo| - mo.vm.box = "mo-focal-#{version_date}" - mo.vm.box_url = "http://images.mushroomobserver.org/mo-focal-#{version_date}.box" + version_date = "2022-11-30" + config.vm.define "mo-jammy-#{version_date}", primary: true do |mo| + mo.vm.box = "mo-jammy-#{version_date}" + mo.vm.box_url = "https://images.mushroomobserver.org/mo-jammy-#{version_date}.box" mo.vm.network "forwarded_port", guest: 3000, host: 3000 mo.vm.provider "virtualbox" do |vb| # Use VBoxManage to customize the VM. For example to change memory: From 8c12c6cded1e42b3f33eaa64bcfa3a12d7705fa0 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Thu, 1 Dec 2022 13:23:05 -0800 Subject: [PATCH 2/3] Current state of nonworking upgrade --- VAGRANT_UPGRADES.md | 62 +++++++++++++++++++++++++++------------------ Vagrantfile | 42 ++++++++++++++---------------- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/VAGRANT_UPGRADES.md b/VAGRANT_UPGRADES.md index e20015a..64a02d7 100644 --- a/VAGRANT_UPGRADES.md +++ b/VAGRANT_UPGRADES.md @@ -8,7 +8,7 @@ system, the version Ruby or various other core components of the VM. 1) Update VirtualBox and Vagrant It's recommended that you always update to the latest version of -VirtualBox and Vagrant at the start of this process. +[VirtualBox](https://www.virtualbox.org/wiki/Downloads) and [Vagrant](https://developer.hashicorp.com/vagrant/downloads) at the start of this process. 2) Destroy or set aside any old boxes. @@ -27,13 +27,13 @@ and could cause issues with: 4) Update the Vagrantfile -For operating system upgrades, I generally go to the Vagrant Boxes +For operating system upgrades, I generally go to the [Vagrant Boxes](https://app.vagrantup.com/boxes/search) search page on the HashiCorp website and search for the OS I'm looking for. When doing an OS upgrade I look first for a Hashicorp box and if I there isn't one, then I'll look for an Ubuntu one. In the current -Vagrantfile we're using "ubuntu/focal64". +Vagrantfile we're using `ubuntu/focal64`. For Ruby upgrades you will change the list that looks like: @@ -42,60 +42,72 @@ For Ruby upgrades you will change the list that looks like: IMPORTANT: You must either change the box names in the Vagrant file or destroy any relevant boxes. Vagrant gets a lot of efficiency by relying on cached copies of things, so make sure you clean out anything -you can. You can change "version_date" as a simple way to change the +you can. You can change `version_date` as a simple way to change the name of the default box. -5) Build the "clean" box +5) Build the "clean" box. -In the current case I ran: "vagrant up clean-focal". You can find the current -names by looking in the Vagrantfile and searching for "config.vm.define". +In the current case I ran: + + vagrant up clean-focal + +You can find the current names by looking in the Vagrantfile and searching +for `config.vm.define`. Currently builds generate a few red warnings/errors related signatures and checksums, but everything seems to be working correctly. -6) Create "clean" package +6) Create "clean" package. + +In the current case I ran: -In the current case I ran: "vagrant package clean-focal". + vagrant package clean-focal -This results in a file called package.box. +This results in a file called `package.box`. -Ultimately This should be uploaded to images.mushroomobserver.org and -moved to the directory /images/mo with the right ownership (mo:mo) and -permissions (644). +Ultimately this should be uploaded to `images.mushroomobserver.org` and +moved to the directory `/images/mo` with the right ownership (`mo:mo`) and +permissions (`644`). Before doing this you may want to test it locally by changing the mo.vm.box_url to refer to the local file. Just remember to switch it back to the real URL after you have things working. -In the current case I moved package.box to mo-focal-2022-06-04.box and updated +In the current case I renamed `package.box` to `mo-focal-2022-06-04.box` and updated the variable to point to: -file:///home/nathan/src/developer-startup/mo-focal-2022-06-04.box + file:///home/nathan/src/developer-startup/mo-focal-2022-06-04.box -7) Bring up the vagrant box +7) Bring up the vagrant box. -Run: vagrant up +Run: -This should bring up a version of the box with the new configuration. + vagrant up -Now run: vagrant ssh +This should bring up a version of the box with the new configuration. Now run: + + vagrant ssh This should connect you to the new box. -8) Setup the local build environment +8) Setup the local build environment. + +Run: -Run: mo-dev /vagrant + mo-dev /vagrant This will run bundler and the other bits needed to get the new box setup to actually run MO. -9) Run the tests +9) Run the tests. + +Run: -Run: cd /vagrant/mushroom-observer; rails test + cd /vagrant/mushroom-observer; rails test If everything is green you great! If stuff fails now you have to figure out how to fix it. -10) Don't forget to upload the new box to images.mushroomobserver.org -and update box_url in the Vagrantfile. +10) Don't forget to upload the new box to `images.mushroomobserver.org` +and update `box_url` in the Vagrantfile. diff --git a/Vagrantfile b/Vagrantfile index 3adecb1..7c9dd7e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -28,8 +28,8 @@ Vagrant.configure("2") do |config| clean.vm.network "forwarded_port", guest: 3000, host: 3000 - # Silence warnings "dpkg-preconfigure: unable to re-open stdin" - # Must come before any `apt-get` calls + # Silence dpkg warnings "dpkg-preconfigure: unable to re-open stdin" + # Must come before any `apt-get` Also: Doesn't work! config.vm.provision :shell, inline: <<-SHELL update-locale LANG=en_US.UTF-8 export DEBIAN_FRONTEND=noninteractive @@ -38,8 +38,8 @@ Vagrant.configure("2") do |config| # Update repositories config.vm.provision :shell, inline: "apt-get -y update" - # Upgrade installed packages - config.vm.provision :shell, inline: "apt-get upgrade -y" + # Upgrade installed packages? + # config.vm.provision :shell, inline: "apt-get upgrade -y" # Add Debian and MySQL server clean.vm.provision :shell, inline: <<-SHELL @@ -55,11 +55,13 @@ Vagrant.configure("2") do |config| libgmp3-dev SHELL - # Add public key for rvm and install rvm. + # Add public key for rvm and install rvm for multi-user clean.vm.provision :shell, privileged: false, inline: <<-SHELL # Note: rvm's listed keyservers (incl. MIT.edu) are extremely # unreliable. Hours of inexplicable failure to find the public keys. - # Pro tip - do not use keyservers at all! Grrrrrrrrrr. - AN 11/2022 + # Some say use the ipv4 subdomain! Nope, doesn't work. Grr - AN 11/2022 + # sudo gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + # These may be less secure than keyservers, but at least they load. curl -sSL https://rvm.io/mpapis.asc | gpg --import - curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - @@ -67,27 +69,21 @@ Vagrant.configure("2") do |config| echo 409B6B1796C275462A1703113804BB82D39DC0E3:6: | gpg --import-ownertrust # mpapis@gmail.com echo 7D2BAF1CF37B13E2069D6956105BD0E739499BDB:6: | gpg --import-ownertrust # piotr.kuczynski@gmail.com - curl -sSL https://get.rvm.io | bash -s stable - source ~/.rvm/scripts/rvm - - rvm use --default --install 3.1.2 - # gem install bundler - # gem install railties + curl -sSL https://get.rvm.io | bash -s stable ; / source ~/.rvm/scripts/rvm + rvm install 3.1.2 rvm cleanup all SHELL - # # Add Google Chrome repository and install - # config.vm.provision :shell, inline: <<-SHELL - # wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub|sudo apt-key add - - # sudo sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" > /etc/apt/sources.list.d/google.list' - # # Add Google Chrome for selenium tests - # sudo apt install -y google-chrome-stable + # Uncomment these to add Google Chrome's repository & chrome itself + # config.vm.provision :shell, inline: "wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub|sudo apt-key add -" + # config.vm.provision :shell, inline: "sudo sh -c 'echo \"deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main\" > /etc/apt/sources.list.d/google.list'" + # # Add Google Chrome for selenium tests + # config.vm.provision :shell, inline: "sudo apt install -y google-chrome-stable" - # # This simpler way didn't work: - # # wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/ - # # dpkg -i ~/google-chrome*.deb" - # # apt-get install -f -y" - # SHELL + # NOTE: This simpler way to add Google Chrome didn't work: + # config.vm.provision :shell, inline: "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P ~/" + # config.vm.provision :shell, inline: "dpkg -i ~/google-chrome*.deb" + # config.vm.provision :shell, inline: "apt-get install -f -y" # Add Firefox for selenium. Slow: Do this last in case troubleshooting. config.vm.provision :shell, inline: "apt-get install -y firefox" From 5ba33559a9f17593f90052c1ff4d2ae6bc97f604 Mon Sep 17 00:00:00 2001 From: andrew nimmo Date: Thu, 1 Dec 2022 19:12:43 -0800 Subject: [PATCH 3/3] Update Vagrantfile --- Vagrantfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 7c9dd7e..c69de86 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -69,8 +69,10 @@ Vagrant.configure("2") do |config| echo 409B6B1796C275462A1703113804BB82D39DC0E3:6: | gpg --import-ownertrust # mpapis@gmail.com echo 7D2BAF1CF37B13E2069D6956105BD0E739499BDB:6: | gpg --import-ownertrust # piotr.kuczynski@gmail.com - curl -sSL https://get.rvm.io | bash -s stable ; / source ~/.rvm/scripts/rvm + curl -sSL https://get.rvm.io | bash -s stable + source $HOME/.rvm/scripts/rvm rvm install 3.1.2 + shift rvm cleanup all SHELL