Skip to content

Commit

Permalink
Merge pull request #22 from etalab/upgrade-otp-23
Browse files Browse the repository at this point in the history
Passage à OTP 23 et amélioration de l'image transport
  • Loading branch information
thbar authored Apr 9, 2021
2 parents db12b2b + 63688e3 commit 04cd3d0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# transport-ops
Scripts and config files for provision and deploy transport and required services

## Image naming convention

In the past images were named "betagouv/transport:x.y.z".

Now we name them after the Elixir, Erlang and Alpine versions actually used (like the base `hexpm` image it uses).

* Base name: `hexpm/elixir:1.10.4-erlang-23.2.7.2-alpine-3.13.3`
* Replace `hexpm/elixir:` by `betagouv/transport:elixir-`
* Target name: `betagouv/transport:elixir-1.10.4-erlang-23.2.7.2-alpine-3.13.3`

You can use `rake get_image_name` to build the expected target name out of the `Dockerfile` in automated fashion.

## Production configuration and deployment

The production requires the following services:
Expand Down Expand Up @@ -35,21 +47,23 @@ As a work-around for [#17](https://github.com/etalab/transport-ops/issues/17):
* Build the image locally with the correct tag, and **without cache** to make sure no left-over impact the build:

```
docker build . --no-cache -t betagouv/transport:X.Y.Z
IMAGE_VERSION=$(rake get_image_version)
IMAGE_NAME=betagouv/transport:$IMAGE_VERSION
docker build transport-site --no-cache -t $IMAGE_VERSION
```

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

```
docker run -it --rm betagouv/transport:X.Y.Z /bin/bash -c 'node --version'
docker run -it --rm betagouv/transport:X.Y.Z /bin/bash -c 'elixir --version'
docker run -it --rm betagouv/transport:X.Y.Z /bin/bash -c "erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'"
docker run -it --rm $IMAGE_NAME /bin/bash -c 'node --version'
docker run -it --rm $IMAGE_NAME /bin/bash -c 'elixir --version'
docker run -it --rm $IMAGE_NAME /bin/bash -c "erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'"
```

* Read the [docker push documentation](https://docs.docker.com/engine/reference/commandline/push/)
* List the local images with `docker image ls`
* Filter with `docker image ls | grep "betagouv/transport" | grep "X.Y.Z"`
* Push with `docker image push betagouv/transport:X.Y.Z`
* Filter with `docker image ls | grep "betagouv/transport" | grep $IMAGE_VERSION`
* Push with `docker image push $IMAGE_NAME`
* TODO: handle `latest` (but it is currently unused)

## Useful tricks when upgrading
Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +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/
puts version
end
21 changes: 9 additions & 12 deletions transport-site/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# see https://hub.docker.com/_/elixir
FROM elixir:1.11.3-alpine
# see https://hub.docker.com/r/hexpm/elixir
FROM hexpm/elixir:1.10.4-erlang-23.2.7.2-alpine-3.13.3

RUN apk add nodejs-npm curl yarn bash build-base wget libtool git
# TODO: iconv could probably be removed later
# https://github.com/etalab/transport-site/issues/1591
RUN apk add curl bash build-base wget libtool git gnu-libiconv

# To be removed in favor of multistage build with deterministic version numbers,
# e.g. https://dev.to/quatermain/comment/njf7
RUN apk add nodejs-npm yarn

# Install app dependencies
RUN mix local.hex --force
RUN mix local.rebar --force

# NOTE: development at https://git.savannah.gnu.org/gitweb/?p=libiconv.git
# and publication at https://ftp.gnu.org/pub/gnu/libiconv
RUN wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz
RUN tar -xf libiconv-1.16.tar.gz
RUN cd libiconv-1.16 && ./configure --prefix= && make && make install
RUN libtool --finish /lib
RUN rm libiconv-1.16.tar.gz
RUN rm -r libiconv-1.16

0 comments on commit 04cd3d0

Please sign in to comment.