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

Mises à jour techniques (Elixir, Erlang, NVM, NodeJS) #33

Merged
merged 18 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: ${{ github.repository }}:test
TEST_EXPECTED_NODE_OUTPUT: "v14.16.1"
TEST_EXPECTED_ELIXIR_OUTPUT: "Elixir 1.12.2 (compiled with Erlang/OTP 24)"
TEST_EXPECTED_ERLANG_OUTPUT: "Erlang/OTP 24"
TEST_EXPECTED_NODE_OUTPUT: "v16.14.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Il faudra vérifier la compatibilité du côté site.

TEST_EXPECTED_ELIXIR_OUTPUT: "Elixir 1.13.2 (compiled with Erlang/OTP 24)"
TEST_EXPECTED_ERLANG_OUTPUT: "24.2.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attention on fait un "gros saut" sur OTP, il faudra être vigilant (aspects HTTP etc).

jobs:
build-and-push-image:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -66,8 +66,8 @@ jobs:
- name: Test that Elixir can start and has expected version
run: docker run --rm ${{ env.TEST_TAG }} /bin/bash -c 'elixir --version' | grep '${{ env.TEST_EXPECTED_ELIXIR_OUTPUT }}'

- name: Test that Erlang can start and has (major) expected version
run: docker run --rm ${{ env.TEST_TAG }} /bin/bash -c "erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'" | grep '${{ env.TEST_EXPECTED_ERLANG_OUTPUT }}'
- name: Test that Erlang can start and has expected version (major + minor + optional revision number)
run: docker run --rm ${{ env.TEST_TAG }} /bin/bash -c "erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), io:fwrite(Version), halt().' -noshell" | grep '${{ env.TEST_EXPECTED_ERLANG_OUTPUT }}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Le test ci-dessus est amélioré et vérifie la totalité de la version (24.2.1 plutôt que juste 24).


# If we reach this point, we consider the tested imaged is OK, so we can extract the metadat & publish
# https://github.com/docker/metadata-action
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,18 @@ As a work-around for [#17](https://github.com/etalab/transport-ops/issues/17):
```
IMAGE_VERSION=$(rake get_image_version)
IMAGE_NAME=betagouv/transport:$IMAGE_VERSION
docker build transport-site --no-cache -t $IMAGE_NAME
docker build transport-site --no-cache -t $IMAGE_NAME --progress=plain
```

* Carefully verify the versions (this will be translated into a testing script later):

```
docker run -it --rm $IMAGE_NAME /bin/bash -c 'node --version'
docker run -it --rm $IMAGE_NAME /bin/bash -c 'elixir --version'
# only major
docker run -it --rm $IMAGE_NAME /bin/bash -c "erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'"
# full version (https://stackoverflow.com/a/34326368)
docker run -it --rm $IMAGE_NME /bin/bash -c "erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), io:fwrite(Version), halt().' -noshell"
```

* Read the [docker push documentation](https://docs.docker.com/engine/reference/commandline/push/)
Expand All @@ -88,7 +91,7 @@ Before creating a tag, the following commands can be used to verify the versions

```
cd transport-site
docker build . -t test:latest
docker build . -t test:latest --progress=plain
docker run -it --rm test:latest /bin/bash -c 'node --version'
docker run -it --rm test:latest /bin/bash -c 'elixir --version'
docker run -it --rm test:latest /bin/bash -c "erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'"
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
task :get_image_version do
version = IO.read("transport-site/Dockerfile")[/FROM (hexpm\/elixir.*)/, 1]
version = version.gsub('hexpm/elixir:','elixir-')
fail "Unexpected FROM format, script must be verified" unless version =~ /\Aelixir\-[^\-]+\-erlang\-[^\-]+\-alpine\-[^\-]+\z/
fail "Unexpected FROM value (got #{version}), script must be adapted?" unless version =~ /\Aelixir\-[^\-]+\-erlang\-[^\-]+\-ubuntu\-focal\-[^\-]+\z/
puts version
end
41 changes: 33 additions & 8 deletions transport-site/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# We leverage the base images published by hexpm.
# We are interested in the binaries compiled on that container:
FROM ghcr.io/etalab/transport-tools:v1.0.2 as transport-tools

# We leverage the base images published by hexpm at:
#
# https://hub.docker.com/r/hexpm/elixir
#
# Which are built via:
#
# https://github.com/hexpm/bob#docker-images
#
# They provide the ability to decouple Elixir version
# and OTP version, which is a nice feature for
# incremental/decoupled upgrades.
Expand All @@ -10,11 +17,11 @@
# - https://github.com/elixir-lang/elixir/releases
# - https://github.com/erlang/otp/releases
#

# We are interested in the binaries compiled on that container:
FROM ghcr.io/etalab/transport-tools:v1.0.2 as transport-tools

FROM hexpm/elixir:1.12.2-erlang-24.0.4-ubuntu-focal-20210325
#
# So again, to upgrade this, check out :
#
# https://hub.docker.com/r/hexpm/elixir
FROM hexpm/elixir:1.13.2-erlang-24.2.1-ubuntu-focal-20211006

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
Expand All @@ -27,10 +34,28 @@ RUN apt-get update && apt-get install -y \
tzdata \
zip

ENV NVM_VERSION v0.29.0
ENV NODE_VERSION 14.16.1
# Helps bump the output of /etc/os-release from says "Ubuntu 24.04.2 LTS" to "... 24.04.3"
#
# The source image (hex) is itself based on a ubuntu image whose
# packages are not necessarily up-to-date all the time. We want to
# upgrade and ensure we are as up-to-date as possible.
# Note that the kernel itself cannot be upgraded here apparently
# (https://stackoverflow.com/a/66413248)
#
# See https://github.com/etalab/transport_deploy/issues/46 for more context
RUN apt-get upgrade -y

# debugging information
RUN uname --all
RUN cat /etc/os-release
RUN cat /etc/lsb-release

ENV NVM_VERSION v0.39.1
ENV NODE_VERSION 16.14.0
ENV NVM_DIR $HOME/.nvm

RUN mkdir $NVM_DIR

# Install NVM
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash

Expand Down