As usual, we're updating the bundler version in our Gemfile.lock so it
uses the one included in Ruby 3.2.3, and we're also updating the
`parser` gem so it supports this version.
Debian Bullseye was released in 2021 and Debian Buster only receives
security updates.
Note that the libindicator7 package is no longer available in this
distribution. However, we were only installing it in order to install
chromedriver, which we don't do since commit 59b625a5f, so we don't need
it anymore.
Note that, even if we're excluding the `node_modules/` folder from
version control, we aren't adding it to Capistrano's shared folders
because, when `node_modules` is a symbolic link, NPM removes it when
running `npm install`.
We're choosing version 18 because if offers support for SSL 3, just
like Ruby 3.1 does.
Note we're symlinking a .nvmrc file as well, in order to make it
compatible with NVM. While the .nvmrc and .node-version files use
different formats, they both support the syntax we're using to
define the version.
The code to install Node.js in the Dockerfile is a simplification of the
code in the Rails Dockerfile template [1].
[1] https://github.com/rails/rails/blob/04c97aec8a/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt#L25
Note we updated the `mail` gem in commit 103742847, which is necesary
for Ruby 3.1 because it adds the net-smtp dependency. The net-smtp
library was removed from Ruby in Ruby 3.1, and if we don't include it,
we get an error:
```
cannot load such file -- net/smtp (LoadError)
```
We're also updating the Bundler version in the Gemfile.lock so it's the
one included in Ruby 3.1. Without updating it, we get a warning:
```
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)'
has been deprecated. Please call `DidYouMean.correct_error(error_nam e,
spell_checker)' instead.
```
Finally, in order to make Capistrano work, we need to add a couple more
changes:
* Make the net-ssh gem compatible with SSL 3.0; done in commit b2eec088b
* Explicitly allow aliases in the `deploy-secrets.yml` file because
Psych 4.x (included in Ruby 3.1) doesn't load aliases without this
option
With one package in line and in alphabetic order, it's easier to see
which packages we're installing.
We're also applying the same formatting (taking from the Docker
documentation [1]) to other lines running multiple instructions.
[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
Quoting the Docker documentation [1]:
> Always combine RUN apt-get update with apt-get install in the same RUN
> statement.
> (...)
> Using apt-get update alone in a RUN statement causes caching issues
> and subsequent apt-get install instructions fail.
> (...)
> Docker sees the initial and modified instructions as identical and
> reuses the cache from previous steps. As a result the apt-get update
> is not executed because the build uses the cached version. Because the
> apt-get update is not run, your build can potentially get an outdated
> version of the curl and nginx packages.
>
> Using RUN apt-get update && apt-get install -y ensures your Dockerfile
> installs the latest package versions with no further coding or manual
> intervention.
[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
The --full-index option seemed to be causing caching issues on some
systems.
Since we don't know the reason why this option was added in the first
place, it might have some advantages. However, some people have reported
problems getting "version can no longer be found" errors for some gems
in this step, and documentation for Docker and Rails doesn't mention
this option at all.
I think we could have already done so when upgrading Ruby to version
2.6.x (which also included the Bundler gem), but since we didn't, now
that we've upgraded to Bundler 2.x it's probably a good moment.
Debian Bullseye was released two days ago, and is now the default
distribution for the Docker image.
Our image isn't compatible with Debian Bullseye right now, and we
haven't done any testing with it, so for now we're staying with Buster.
Our Docker image uses Chromium v57, which is not supported by
chromedriver versions after 2.38. See
https://bugs.chromium.org/p/chromedriver/issues/detail?id=2445
The reason that the version of chromium is so old is that our base
image ruby:2.3.6 (the standard image for Ruby 2.3.6 on DockerHub) is
built on Debian 8 (jessie), which was made obsolete over a year ago.
The best solution is probably to upgrade the application to Ruby 2.3.7
(if not later), so we can use the official ruby:2.3.7 image, which is
kept up-to-date (it has Chromium 68).
Alternatively, we could try to install Chromium from a more up-to-date
repository, but this is probably not worth the trouble.
The following enhancements have been made to docker/docker-compose
* Fixed bug when building the image.
* docker-compose up starts the server
* Scaffolding inside the container respect the ownership of the files
outside it
* Volumes are tagged as 'delegated' in order to improve performance for
mac/windoze users.
* bundler stores packages in a volume. This whay new packages can be
added without rebuilding the image:
```bash
docker-compose run app bundle install
```