From 57e5d26fdb0149594e9e5846cb3d0cc68345b145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 16:45:23 +0200 Subject: [PATCH 01/16] Bump OTP to 23.3 --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index 79882d42ef..ab2459a825 100644 --- a/.tool-versions +++ b/.tool-versions @@ -7,12 +7,12 @@ # - https://hexdocs.pm/elixir/compatibility-and-deprecations.html # - https://github.com/elixir-lang/elixir/releases # - `asdf list all elixir` -elixir 1.10.4-otp-22 +elixir 1.10.4-otp-23 # See: # - https://github.com/erlang/otp/releases # - https://github.com/erlang/otp/blob/master/otp_versions.table # - `asdf list all erlang` -erlang 22.3.4.12 +erlang 23.3.1 nodejs 12.15.0 From ec644b3de7d7264d1bc0da7402ab98a2c6d655f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 17:25:35 +0200 Subject: [PATCH 02/16] Bump up Elixir to 1.11 & OTP to 23 via base image change --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 242bccdc70..083bf0ad7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM betagouv/transport:0.4.5 +FROM betagouv/transport:0.5.0 RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv-dev RUN apk add git From 5fb6dc79f52294ee235e5b42145d98d1c867b9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 17:28:29 +0200 Subject: [PATCH 03/16] Adjust version to be more accurate I have traced what OTP version could have been used by `elixir:1.11.3-alpine`. There is not a strict truth here yet, but: `erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'` provided a bit of partial information (e.g. Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]), and then "erts-11.1.8" appears 5 times in https://github.com/erlang/otp/blob/master/otp_versions.table. I picked the most recent match. --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index ab2459a825..123f1a63c8 100644 --- a/.tool-versions +++ b/.tool-versions @@ -13,6 +13,6 @@ elixir 1.10.4-otp-23 # - https://github.com/erlang/otp/releases # - https://github.com/erlang/otp/blob/master/otp_versions.table # - `asdf list all erlang` -erlang 23.3.1 +erlang 23.2.7.2 nodejs 12.15.0 From 661bbe2fd50a5f5f982741bfa2d23f97dc99892c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 17:43:05 +0200 Subject: [PATCH 04/16] Bump CI docker image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 35f583ecdf..f15fe85c0e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 # useful information at https://circleci.com/docs/2.0/language-elixir/ default_docker: &default_docker - image: betagouv/transport:0.4.5 + image: betagouv/transport:0.5.0 environment: MIX_ENV: test PG_URL_TEST: ecto://root@127.0.0.1/transport_test From 29c009530d433a6ddaf070c9687a393c5b31ee54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 17:51:37 +0200 Subject: [PATCH 05/16] Modify the Postgres container (fixes #1517) The previous one is not updated. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f15fe85c0e..b49a27d814 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,7 @@ defaults_with_postgres: &defaults_with_postgres <<: *defaults docker: - *default_docker - - image: mdillon/postgis:11-alpine + - image: postgis/postgis/12-3.0-alpine environment: POSTGRES_USER: root POSTGRES_DB: transport_test From 2683eba49f1ea12058affad4db873eb2bc607db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 18:04:05 +0200 Subject: [PATCH 06/16] Stop installing git See https://github.com/etalab/transport-ops/issues/19 --- .circleci/config.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b49a27d814..a895a78566 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,11 +33,6 @@ jobs: steps: - checkout - # TODO: remove this once https://github.com/etalab/transport-ops/issues/19 is solved - - run: - name: Install git (required if we use git-hosted hex packages) - command: apk add --update git - - restore_cache: keys: - elixir-v9-build-{{ checksum "mix.lock" }} @@ -113,10 +108,6 @@ jobs: - attach_workspace: at: ~/transport - - run: - name: Install git (required if we use git-hosted hex packages) - command: apk add --update git - - run: name: Run linters command: | @@ -142,10 +133,6 @@ jobs: - attach_workspace: at: ~/transport - - run: - name: Install git (required if we use git-hosted hex packages) - command: apk add --update git - - run: name: Run dialyzer (static analysis) command: MIX_ENV=dev mix dialyzer @@ -156,10 +143,6 @@ jobs: - attach_workspace: at: ~/transport - - run: - name: Install git (required if we use git-hosted hex packages) - command: apk add --update git - - run: name: Run tests command: | @@ -173,10 +156,6 @@ jobs: - attach_workspace: at: ~/transport - - run: - name: Install git (required if we use git-hosted hex packages) - command: apk add --update git - - run: name: Run tests command: | From 014f621b973c77b5e46541bbe2221c30147178e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 18:05:25 +0200 Subject: [PATCH 07/16] Automatically invalidate cache when image is updated Extracted from #1515. --- .circleci/config.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a895a78566..a1b1b6c967 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,10 @@ -version: 2 +version: 2.1 # useful information at https://circleci.com/docs/2.0/language-elixir/ +# and https://circleci.com/docs/2.0/reusing-config/#using-the-parameters-declaration default_docker: &default_docker - image: betagouv/transport:0.5.0 + image: << parameters.base_image >> environment: MIX_ENV: test PG_URL_TEST: ecto://root@127.0.0.1/transport_test @@ -13,6 +14,10 @@ default_docker: &default_docker SECRET_KEY_BASE: "SOME-SECRET-KEY-BASE-FOR-TESTING-SOME-SECRET-KEY-BASE-FOR-TESTING" defaults: &defaults + parameters: + base_image: + default: betagouv/transport:0.5.0 + type: string working_directory: ~/transport docker: - *default_docker @@ -35,7 +40,7 @@ jobs: - restore_cache: keys: - - elixir-v9-build-{{ checksum "mix.lock" }} + - elixir-<< parameters.base_image >>-{{ checksum "mix.lock" }} - run: name: Install hex @@ -62,7 +67,7 @@ jobs: command: mix deps.compile - save_cache: - key: elixir-v9-build-{{ checksum "mix.lock" }} + key: elixir-<< parameters.base_image >>-{{ checksum "mix.lock" }} paths: - ~/transport/_build - ~/transport/deps @@ -82,7 +87,7 @@ jobs: - restore_cache: keys: - - elixir-v8-plt-{{ checksum "mix.lock" }} + - elixir-<< parameters.base_image >>-plt-{{ checksum "mix.lock" }} - run: name: Build PLT @@ -92,7 +97,7 @@ jobs: no_output_timeout: 20m - save_cache: - key: elixir-v8-plt-{{ checksum "mix.lock" }} + key: elixir-<< parameters.base_image >>-plt-{{ checksum "mix.lock" }} paths: - ~/transport/dialyzer-plt From faf2033d84b645dbd42e9fa26c3838bb5266ef55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 19:12:48 +0200 Subject: [PATCH 08/16] Start testing against elixir 10.4 + OTP 23 testing image --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a1b1b6c967..88624d895e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,8 @@ default_docker: &default_docker defaults: &defaults parameters: base_image: - default: betagouv/transport:0.5.0 + # TODO: move to stable release + default: betagouv/transport:develop type: string working_directory: ~/transport docker: From c16a88cef60a8c547d5691d057fb832c00c7d417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 19:46:01 +0200 Subject: [PATCH 09/16] Work around "docker pull login" error by using CircleCI rough equivalent --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 88624d895e..08e9973885 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ defaults_with_postgres: &defaults_with_postgres <<: *defaults docker: - *default_docker - - image: postgis/postgis/12-3.0-alpine + - image: circleci/postgres:12.0-alpine-postgis environment: POSTGRES_USER: root POSTGRES_DB: transport_test From 558542937ab278ca9fe776e16c8b13552dc380b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 8 Apr 2021 19:58:57 +0200 Subject: [PATCH 10/16] Bump Node to latest LTS This is required because I'm rebuilding the base image today, which installs at the moment the latest LTS. --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index 123f1a63c8..94ffd0246a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -15,4 +15,4 @@ elixir 1.10.4-otp-23 # - `asdf list all erlang` erlang 23.2.7.2 -nodejs 12.15.0 +nodejs 14.16.1 From 2034d9e27a3c5382f32182a81d836133a56b4dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Fri, 9 Apr 2021 17:15:55 +0200 Subject: [PATCH 11/16] Upgrade only OTP to 23 (not Elixir) --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08e9973885..48acbc7f77 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,8 +16,7 @@ default_docker: &default_docker defaults: &defaults parameters: base_image: - # TODO: move to stable release - default: betagouv/transport:develop + default: betagouv/transport:elixir-1.10.4-erlang-23.2.7.2-alpine-3.13.3 type: string working_directory: ~/transport docker: From ad5ac912f229c24c6293a6c23d550999904b2d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 20 Apr 2021 09:30:06 +0200 Subject: [PATCH 12/16] Add a test to make sure we do not forget updating production image --- apps/transport/test/build_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/transport/test/build_test.exs b/apps/transport/test/build_test.exs index 53372673cc..805e1c8134 100644 --- a/apps/transport/test/build_test.exs +++ b/apps/transport/test/build_test.exs @@ -33,6 +33,16 @@ defmodule TransportWeb.BuildTest do assert output |> String.trim() == "v" <> asdf_nodejs_release() end + test "make sure Docker image is same for production & CI" do + content = File.read!("../../Dockerfile") + [[_, production_version]] = Regex.scan(~r/FROM (.*)/, content) + + content = File.read!("../../.circleci/config.yml") + [[_, ci_version]] = Regex.scan(~r/(betagouv\/transport.*)/, content) + + assert ci_version == production_version + end + # figuring out you have forgotten to upgrade the assets can be tricky, so we add a little reminder here test "make sure LiveView client assets are up to date" do {output, 0} = System.cmd("yarn", ["list", "--pattern", "phoenix_live_view"], cd: "client") From b384f51ee93fa19cb3d6db7fed7960ae1094e589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 20 Apr 2021 09:41:16 +0200 Subject: [PATCH 13/16] Update prod docker image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 083bf0ad7a..f5259a5b69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM betagouv/transport:0.5.0 +FROM betagouv/transport:elixir-1.10.4-erlang-23.2.7.2-alpine-3.13.3 RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv-dev RUN apk add git From 839825eec5a256390fb24adc8a39a6e4c22f9ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 20 Apr 2021 09:46:38 +0200 Subject: [PATCH 14/16] Remove git (already in base image) --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f5259a5b69..4eb8045c9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM betagouv/transport:elixir-1.10.4-erlang-23.2.7.2-alpine-3.13.3 RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv-dev -RUN apk add git RUN mkdir phoenixapp WORKDIR /phoenixapp From ece349880bbc84f1706ac84614272354e1ebc3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 20 Apr 2021 09:51:03 +0200 Subject: [PATCH 15/16] Fix compilation warning --- apps/shared/test/http_stream_v2_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/shared/test/http_stream_v2_test.exs b/apps/shared/test/http_stream_v2_test.exs index 98ada0a261..b4869a3e88 100644 --- a/apps/shared/test/http_stream_v2_test.exs +++ b/apps/shared/test/http_stream_v2_test.exs @@ -20,7 +20,7 @@ defmodule HTTPStreamV2.Test do assert result.hash == :sha256 |> :crypto.hash("Contenu éphémère") |> Base.encode16 |> String.downcase assert result.body_byte_size == ("Contenu éphémère" |> byte_size()) headers = result.headers - |> Enum.filter(fn({a, b}) -> a == "hello" end) + |> Enum.filter(fn({key, _val}) -> key == "hello" end) assert headers == [{"hello", "header"}] end From 58f98974262831fdb42379f9e4d0bedef55f2c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 20 Apr 2021 11:16:34 +0200 Subject: [PATCH 16/16] Trigger deploy