Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read versions from .tool-versions when building production image #464

Conversation

gerhard
Copy link
Member

@gerhard gerhard commented May 20, 2023

In order to minimize bugs and differences in behaviour between dev & prod, we want to be running the same runtime dependency versions (e.g. Erlang, Elixir, Node.js & PostgreSQL) in both environments.

In development, we are using https://asdf-vm.com/ to manage runtime dependencies. This means that with a single command - asdf install - everyone working with our codebase can have the same dependencies installed. Currently these are:

  • direnv 2.32.2
  • elixir 1.14.4
  • erlang 25.3.2
  • golang 1.20.4
  • nodejs 18.16.0
  • yarn 1.22.19
  • postgres 14.1
  • flyctl 0.1.8

We used to manually edit these versions in our CI/CD pipeline. Since we are using Dagger for CI/CD, this was no big deal since our pipeline is just code. But since it is code, we could go one step further. Our pipeline could read the .tool-versions file and use that information to build the container image that gets deployed to production. That's exactly what this change does.

The only runtime dependency version that does not exist in .tool-versions is the OS - Ubuntu 22.04 in production. This is a reasonable limitation that we could improve as a follow-up. What I am thinking right now is that we should NOT depend on an OS for the production container image, and instead finish the migration to Elixir (Erlang) releases + one of those sweet
https://github.com/chainguard-images/images#chainguard-images, maybe https://github.com/chainguard-images/images/tree/main/images/glibc-dynamic . What we are really missing is an Elixir Chainguard image. One day...

Boy scout fixes:

  • upgrade Erlang, Node.js & Golang to latest minor
  • upgrade Dagger Go SDK to latest
  • go mod tidy
  • improve Dagger pipeline grouping
  • run pipelines in parallel 🏎 Turbo button 🏎
  • use the same PostgreSQL minor in devcontainer - same version everywhere!
  • upgrade flyctl version to latest
  • install yarn, flyctl & mage via asdf
  • use shorter mage commands instead of go run main.go -w ..
  • test asdf on a fresh macOS 16.3 (arm64)
  • test asdf on Debian 11
  • upgrade setup-go GitHub Action to v4

TODO

  • Open as draft PR so that we run through GitHub Actions (all looking good locally)
  • Update CONTRIBUTING.md by running on a fresh macOS
  • Update .devcontainer/docker-compose.yml

@gerhard gerhard force-pushed the read-production-versions-from-tool-versions branch 6 times, most recently from a3680d7 to aec54bf Compare May 20, 2023 19:12
@gerhard gerhard marked this pull request as ready for review May 20, 2023 19:13
@gerhard gerhard requested a review from jerodsanto May 20, 2023 19:14
@gerhard gerhard force-pushed the read-production-versions-from-tool-versions branch from aec54bf to 775a7f0 Compare May 20, 2023 20:55
In order to minimize bugs and differences in behaviour between dev &
prod, we want to be running the same runtime dependency versions (e.g.
Erlang, Elixir, Node.js & PostgreSQL) in both environments.

In development, we are using https://asdf-vm.com/ to manage runtime
dependencies. This means that with a single command - asdf install -
everyone working with our codebase can have the same dependencies
installed. Currently these are:
- direnv 2.32.2
- elixir 1.14.4
- erlang 25.3.2
- golang 1.20.4
- nodejs 18.16.0
- yarn 1.22.19
- postgres 14.1
- flyctl 0.1.8
- mage 1.15.0

We used to manually edit these versions in our CI/CD pipeline. Since we
are using Dagger for CI/CD, this was no big deal since our pipeline is
just code. But since it is code, we could go one step further. Our
pipeline could read the .tool-versions file and use that information
to build the container image that gets deployed to production. That's
exactly what this change does.

The only runtime dependency version that does not exist in
.tool-versions is the OS - Ubuntu 22.04 in production. This is a
reasonable limitation that we could improve as a follow-up. What I am
thinking right now is that we should NOT depend on an OS for the
production container image, and instead finish the migration to Elixir
(Erlang) releases + one of those sweet
https://github.com/chainguard-images/images#chainguard-images, maybe
https://github.com/chainguard-images/images/tree/main/images/glibc-dynamic.
What we are really missing is an Elixir Chainguard image. One day...

Boy scout fixes:
+ upgrade Erlang, Node.js & Golang to latest minor
+ upgrade Dagger Go SDK to latest
+ go mod tidy
+ improve Dagger pipeline grouping
+ run pipelines in parallel 🏎 Turbo button 🏎
+ use the same PostgreSQL minor in devcontainer - same version everywhere!
+ upgrade flyctl version to latest
+ install yarn, flyctl & mage via asdf
+ use shorter mage commands instead of go run
+ test asdf on a fresh macOS 16.3 (arm64)
+ test asdf on Debian 11
+ upgrade setup-go GitHub Action to v4

Signed-off-by: Gerhard Lazu <[email protected]>
@gerhard gerhard force-pushed the read-production-versions-from-tool-versions branch from 775a7f0 to 0571e8a Compare May 20, 2023 21:08
Copy link
Member

@jerodsanto jerodsanto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@gerhard gerhard merged commit f6bf465 into thechangelog:master May 23, 2023
@gerhard gerhard deleted the read-production-versions-from-tool-versions branch May 23, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants