diff --git a/README.md b/README.md index 6ecb0c8..563b226 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..6265732 --- /dev/null +++ b/Rakefile @@ -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 diff --git a/transport-site/Dockerfile b/transport-site/Dockerfile index beb4a61..9505d2d 100644 --- a/transport-site/Dockerfile +++ b/transport-site/Dockerfile @@ -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