diff --git a/README.md b/README.md index e4d3a14..7b61e06 100644 --- a/README.md +++ b/README.md @@ -8,27 +8,27 @@ These Dockerfiles are used to build docker images we use for various 1. Clone this repo 2. Edit the Dockerfile you want to update -3. Keep the primary version number of the image in sync with the Elixir version. +3. Keep the primary version number of the image in sync with the Elixir version and its base erlang/otp version. So tag '1.6.2' should be Elixir version 1.6.2. Any changes to the Dockerfile - that are not Elixir version related should increase the letter version. + that are not Elixir version or base image version related should increase the letter version. 4. Build and push an image with a version tag Calling `push.sh` with no argument will use the directory name as the tag. For example, the following command will push an `erlang` image with the tags -`20.2.4` and `latest` to Dockerhub: +`22.1.3-alpine` and `alpine-latest` to Dockerhub: ``` -cd erlang/20.2.4 -../../push.sh +cd erlang/22.1.3/alpine +../../../push.sh ``` If an argument is passed to `push.sh`, it will be used as a suffix appended with a `-` to the current directory name. For example, the following command will -push an `elixir` image with the tags `1.6.2-b` and `latest` to Dockerhub: +push an `elixir` image with the tags `1.9.2-alpine-otp22` and `alpine-latest` to Dockerhub: ``` -cd elixir/1.6.2 -../../push.sh b +cd elixir/1.9.2/alpine +../../../push.sh otp22 ``` #### Notes @@ -38,6 +38,42 @@ cd elixir/1.6.2 namespace. 2. Test out your changes on a tag before committing and pushing to latest. +## Multistage Docker Build for Production + +Lower final image size by using multistage docker build and avvo/alpine image. + +```Dockerfile +FROM avvo/elixir:1.9.4-otp22-alpine-3.9 AS build + +ENV MIX_ENV=prod + +COPY . . + +# If you have assets to build +RUN cd assets \ + && npm install \ + && npm run deploy \ + && cd ../ + +RUN mix phx.digest + +RUN mix do deps.get, compile, release + +FROM avvo/elixir-release:alpine-3.9 + +EXPOSE 4000 + +WORKDIR /srv/app_name + +COPY --from=build ./_build/prod/app_name-APP_VERSION.tar.gz . + +RUN tar zxf app_name-APP_VERSION.tar.gz \ + && rm app_name-APP_VERSION.tar.gz + +ENTRYPOINT ["avvoenv", "exec"] +CMD ["bin/app_name", "start"] +``` + ## License MIT Licence. Do what you want, this is just configuration, nothing special. diff --git a/elixir-circleci/Dockerfile b/elixir-circleci/Dockerfile deleted file mode 100644 index 2efdcc2..0000000 --- a/elixir-circleci/Dockerfile +++ /dev/null @@ -1,49 +0,0 @@ -FROM ubuntu:xenial - -# For latest ERLANG_OTP_VERSION, see: https://packages.erlang-solutions.com/erlang/ -# For latest NODE_VERSION, see: https://github.com/nodesource/distributions/tree/master/deb - -ENV \ - ELIXIR_VERSION='1.5.2-1' \ - ERLANG_OTP_VERSION='20.1.7' \ - HOME='/opt/app/' \ - LANG='C.UTF-8' \ - MIX_ENV='test' \ - NODE_VERSION='8' \ - TERM='xterm' - -WORKDIR "${HOME}" - -RUN \ - set -xe \ - && apt-get update -qq \ - && apt-get upgrade -y \ - && apt-get install -y \ - apt-transport-https \ - build-essential \ - ca-certificates \ - curl \ - git \ - libmysqlclient-dev \ - postgresql-client \ - mysql-client \ - openssh-client \ - software-properties-common \ - && curl -sL "https://deb.nodesource.com/setup_${NODE_VERSION}.x" | bash - \ - && ERLANG_PKG='erlang-solutions_1.0_all.deb' \ - && ERLANG_URL="https://packages.erlang-solutions.com/${ERLANG_PKG}" \ - && curl -o "/tmp/${ERLANG_PKG}" ${ERLANG_URL} \ - && dpkg -i "/tmp/${ERLANG_PKG}" \ - && apt-get update -qq \ - && apt-get upgrade -y \ - && apt-get install -y \ - nodejs \ - "elixir=${ELIXIR_VERSION}" \ - "esl-erlang=1:${ERLANG_OTP_VERSION}" \ - && rm -rf '/var/lib/apt/lists/*' \ - && mix local.hex --force \ - && mix local.rebar --force \ - && mkdir -p '/root/.ssh' \ - && ssh-keyscan -t rsa github.com > '/root/.ssh/known_hosts' \ - && chmod 700 '/root/.ssh' \ - && chmod 600 '/root/.ssh/known_hosts' diff --git a/elixir-release/3.6/Dockerfile b/elixir-release/alpine/3.6/Dockerfile similarity index 100% rename from elixir-release/3.6/Dockerfile rename to elixir-release/alpine/3.6/Dockerfile diff --git a/elixir-release/alpine/3.9/Dockerfile b/elixir-release/alpine/3.9/Dockerfile new file mode 100644 index 0000000..e262967 --- /dev/null +++ b/elixir-release/alpine/3.9/Dockerfile @@ -0,0 +1,7 @@ +FROM avvo/alpine:3.9 + +RUN set -xe \ + && apk --no-cache upgrade \ + && apk add --no-cache \ + ncurses-libs \ + openssl diff --git a/elixir-release-ubuntu/18.04/Dockerfile b/elixir-release/ubuntu/18.04/Dockerfile similarity index 100% rename from elixir-release-ubuntu/18.04/Dockerfile rename to elixir-release/ubuntu/18.04/Dockerfile diff --git a/elixir-release-ubuntu/xenial/Dockerfile b/elixir-release/ubuntu/xenial/Dockerfile similarity index 100% rename from elixir-release-ubuntu/xenial/Dockerfile rename to elixir-release/ubuntu/xenial/Dockerfile diff --git a/elixir/1.10.2/alpine/Dockerfile b/elixir/1.10.2/alpine/Dockerfile new file mode 100644 index 0000000..7da0209 --- /dev/null +++ b/elixir/1.10.2/alpine/Dockerfile @@ -0,0 +1,34 @@ +FROM avvo/erlang:22-alpine-11 + +# Adapted from: +# https://github.com/c0b/docker-elixir/blob/master/1.9/Dockerfile + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.10.2" \ + LANG=C.UTF-8 + +RUN set -xe \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="5adffcf4389aa82fcfbc84324ebbfa095fc657a0e15b2b055fc05184f96b2d50" \ + && buildDeps=' \ + ca-certificates \ + curl \ + make \ + ' \ + && apk --no-cache upgrade \ + && apk add --no-cache --virtual .build-deps $buildDeps \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean \ + && apk del .build-deps \ + && mix local.hex --force \ + && mix local.rebar --force \ + && mkdir -p '/root/.ssh' \ + && apk add --no-cache openssh-client build-base npm git \ + && ssh-keyscan -t rsa github.com > '/root/.ssh/known_hosts' \ + && chmod 700 '/root/.ssh' \ + && chmod 600 '/root/.ssh/known_hosts' diff --git a/elixir/1.10.4/alpine/Dockerfile b/elixir/1.10.4/alpine/Dockerfile new file mode 100644 index 0000000..742ec4e --- /dev/null +++ b/elixir/1.10.4/alpine/Dockerfile @@ -0,0 +1,34 @@ +FROM avvo/erlang:23.0.2-alpine + +# Adapted from: +# https://github.com/c0b/docker-elixir/blob/master/1.10/alpine/Dockerfile + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.10.4" \ + LANG=C.UTF-8 + +RUN set -xe \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="8518c78f43fe36315dbe0d623823c2c1b7a025c114f3f4adbb48e04ef63f1d9f" \ + && buildDeps=' \ + ca-certificates \ + curl \ + make \ + ' \ + && apk --no-cache upgrade \ + && apk add --no-cache --virtual .build-deps $buildDeps \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean \ + && apk del .build-deps \ + && mix local.hex --force \ + && mix local.rebar --force \ + && mkdir -p '/root/.ssh' \ + && apk add --no-cache openssh-client build-base npm git \ + && ssh-keyscan -t rsa github.com > '/root/.ssh/known_hosts' \ + && chmod 700 '/root/.ssh' \ + && chmod 600 '/root/.ssh/known_hosts' diff --git a/elixir/1.6.0/Dockerfile b/elixir/1.6.0/ubuntu/Dockerfile similarity index 100% rename from elixir/1.6.0/Dockerfile rename to elixir/1.6.0/ubuntu/Dockerfile diff --git a/elixir/1.6.1/Dockerfile b/elixir/1.6.1/ubuntu/Dockerfile similarity index 100% rename from elixir/1.6.1/Dockerfile rename to elixir/1.6.1/ubuntu/Dockerfile diff --git a/elixir/1.6.2/Dockerfile b/elixir/1.6.2/ubuntu/Dockerfile similarity index 100% rename from elixir/1.6.2/Dockerfile rename to elixir/1.6.2/ubuntu/Dockerfile diff --git a/elixir/1.6.3/Dockerfile b/elixir/1.6.3/ubuntu/Dockerfile similarity index 100% rename from elixir/1.6.3/Dockerfile rename to elixir/1.6.3/ubuntu/Dockerfile diff --git a/elixir/1.7.4/Dockerfile b/elixir/1.7.4/ubuntu/Dockerfile similarity index 100% rename from elixir/1.7.4/Dockerfile rename to elixir/1.7.4/ubuntu/Dockerfile diff --git a/elixir/1.9.1/Dockerfile b/elixir/1.9.1/ubuntu/Dockerfile similarity index 100% rename from elixir/1.9.1/Dockerfile rename to elixir/1.9.1/ubuntu/Dockerfile diff --git a/elixir/1.9.2/alpine/Dockerfile b/elixir/1.9.2/alpine/Dockerfile new file mode 100644 index 0000000..c616840 --- /dev/null +++ b/elixir/1.9.2/alpine/Dockerfile @@ -0,0 +1,36 @@ +FROM avvo/erlang:22-alpine + +# Adapted from: +# https://github.com/c0b/docker-elixir/blob/master/1.9/Dockerfile + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.9.2" \ + LANG=C.UTF-8 \ + MIX_ENV='test' + +RUN set -xe \ + && STARTING_DIR="$(pwd)" \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="02aaa3ffd21f9cf51aceb3aa5a5bc2c1e2636b1611867e44f19693dcf856e25c" \ + && buildDeps=' \ + ca-certificates \ + curl \ + make \ + ' \ + && apk --no-cache upgrade \ + && apk add --no-cache --virtual .build-deps $buildDeps \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean \ + && apk del .build-deps \ + && mix local.hex --force \ + && mix local.rebar --force \ + && mkdir -p '/root/.ssh' \ + && apk add --no-cache openssh-client build-base npm git \ + && ssh-keyscan -t rsa github.com > '/root/.ssh/known_hosts' \ + && chmod 700 '/root/.ssh' \ + && chmod 600 '/root/.ssh/known_hosts' diff --git a/elixir/1.9.4/alpine/Dockerfile b/elixir/1.9.4/alpine/Dockerfile new file mode 100644 index 0000000..c78d7f6 --- /dev/null +++ b/elixir/1.9.4/alpine/Dockerfile @@ -0,0 +1,36 @@ +FROM avvo/erlang:22-alpine + +# Adapted from: +# https://github.com/c0b/docker-elixir/blob/master/1.9/Dockerfile + +# elixir expects utf8. +ENV ELIXIR_VERSION="v1.9.4" \ + LANG=C.UTF-8 \ + MIX_ENV='test' + +RUN set -xe \ + && STARTING_DIR="$(pwd)" \ + && ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" \ + && ELIXIR_DOWNLOAD_SHA256="f3465d8a8e386f3e74831bf9594ee39e6dfde6aa430fe9260844cfe46aa10139" \ + && buildDeps=' \ + ca-certificates \ + curl \ + make \ + ' \ + && apk --no-cache upgrade \ + && apk add --no-cache --virtual .build-deps $buildDeps \ + && curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL \ + && echo "$ELIXIR_DOWNLOAD_SHA256 elixir-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/local/src/elixir \ + && tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz \ + && rm elixir-src.tar.gz \ + && cd /usr/local/src/elixir \ + && make install clean \ + && apk del .build-deps \ + && mix local.hex --force \ + && mix local.rebar --force \ + && mkdir -p '/root/.ssh' \ + && apk add --no-cache openssh-client build-base npm git \ + && ssh-keyscan -t rsa github.com > '/root/.ssh/known_hosts' \ + && chmod 700 '/root/.ssh' \ + && chmod 600 '/root/.ssh/known_hosts' diff --git a/erlang/20.2.4/Dockerfile b/erlang/20.2.4/ubuntu/Dockerfile similarity index 100% rename from erlang/20.2.4/Dockerfile rename to erlang/20.2.4/ubuntu/Dockerfile diff --git a/erlang/20.3/Dockerfile b/erlang/20.3/ubuntu/Dockerfile similarity index 100% rename from erlang/20.3/Dockerfile rename to erlang/20.3/ubuntu/Dockerfile diff --git a/erlang/20/Dockerfile b/erlang/20/ubuntu/Dockerfile similarity index 100% rename from erlang/20/Dockerfile rename to erlang/20/ubuntu/Dockerfile diff --git a/erlang/22.0.7/Dockerfile b/erlang/22.0.7/Dockerfile deleted file mode 100644 index ff0db2d..0000000 --- a/erlang/22.0.7/Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM avvo/ubuntu:xenial - -# Adapted from: https://github.com/erlang/docker-erlang-otp/blob/master/22/Dockerfile - -ENV \ - OTP_VERSION="22.0.7" \ - OTP_DOWNLOAD_SHA256="04c090b55ec4a01778e7e1a5b7fdf54012548ca72737965b7aa8c4d7878c92bc" \ - REBAR_VERSION="2.6.4" \ - REBAR_DOWNLOAD_SHA256="577246bafa2eb2b2c3f1d0c157408650446884555bf87901508ce71d5cc0bd07" \ - REBAR3_VERSION="3.11.1" \ - REBAR3_DOWNLOAD_SHA256="a1822db5210b96b5f8ef10e433b22df19c5fc54dfd847bcaab86c65151ce4171" - -# We'll install the build dependencies for erlang-odbc along with the erlang -# build process: -RUN set -xe \ - && OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \ - && runtimeDeps=' \ - apt-transport-https \ - ca-certificates \ - curl \ - libgcrypt11-dev \ - libodbc1 \ - libsctp1 \ - libssl-dev \ - libwxgtk3.0 \ - openssh-client \ - ' \ - && buildDeps=' \ - autoconf \ - build-essential \ - libncurses5-dev \ - libncursesw5-dev \ - unixodbc-dev \ - libsctp-dev \ - libwxgtk3.0-dev \ - ' \ - && apt-get update \ - && apt-get install -y --no-install-recommends $runtimeDeps \ - && apt-get install -y --no-install-recommends $buildDeps \ - && curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \ - && echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \ - && export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \ - && mkdir -vp "${ERL_TOP}" \ - && tar -xzf otp-src.tar.gz -C "${ERL_TOP}" --strip-components=1 \ - && rm otp-src.tar.gz \ - && ( \ - cd "${ERL_TOP}" \ - && ./otp_build autoconf \ - && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ - && ./configure --build="${gnuArch}" \ - && make -j$(nproc) \ - && make install \ - ) \ - && find /usr/local -name examples | xargs rm -rf \ - && apt-get purge -y --auto-remove ${buildDeps} \ - && rm -rf "${ERL_TOP}" /var/lib/apt/lists/* - -CMD ["erl"] - -# extra useful tools here: rebar & rebar3 - -RUN set -xe \ - && REBAR_DOWNLOAD_URL="https://github.com/rebar/rebar/archive/${REBAR_VERSION}.tar.gz" \ - && mkdir -p /usr/src/rebar-src \ - && curl -fSL -o rebar-src.tar.gz "${REBAR_DOWNLOAD_URL}" \ - && echo "${REBAR_DOWNLOAD_SHA256} rebar-src.tar.gz" | sha256sum -c - \ - && tar -xzf rebar-src.tar.gz -C /usr/src/rebar-src --strip-components=1 \ - && rm rebar-src.tar.gz \ - && cd /usr/src/rebar-src \ - && ./bootstrap \ - && install -v ./rebar /usr/local/bin/ \ - && rm -rf /usr/src/rebar-src - - -RUN set -xe \ - && REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \ - && mkdir -p /usr/src/rebar3-src \ - && curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \ - && echo "${REBAR3_DOWNLOAD_SHA256} rebar3-src.tar.gz" | sha256sum -c - \ - && tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \ - && rm rebar3-src.tar.gz \ - && cd /usr/src/rebar3-src \ - && HOME=$PWD ./bootstrap \ - && install -v ./rebar3 /usr/local/bin/ \ - && rm -rf /usr/src/rebar3-src diff --git a/erlang/22.1.2/Dockerfile b/erlang/22.1.2/ubuntu/Dockerfile similarity index 100% rename from erlang/22.1.2/Dockerfile rename to erlang/22.1.2/ubuntu/Dockerfile diff --git a/erlang/22.1.3/alpine/Dockerfile b/erlang/22.1.3/alpine/Dockerfile new file mode 100644 index 0000000..c8bf4e2 --- /dev/null +++ b/erlang/22.1.3/alpine/Dockerfile @@ -0,0 +1,68 @@ +FROM avvo/alpine:3.9 + +# Adapted from: https://github.com/erlang/docker-erlang-otp/blob/master/22/alpine/Dockerfile + +ENV OTP_VERSION="22.1.3" \ + REBAR3_VERSION="3.12.0" + +LABEL org.opencontainers.image.version=$OTP_VERSION + +RUN set -xe \ + && OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \ + && OTP_DOWNLOAD_SHA256="53a828c1199a41cb54bd3bc6c2c49af977a8834e702c030a5ea34013a3fcacdd" \ + && REBAR3_DOWNLOAD_SHA256="8ac45498f03e293bc6342ec431888f9a81a4fb9e1177a69965238d127c00a79e" \ + && apk add --no-cache --virtual .fetch-deps \ + curl \ + ca-certificates \ + && curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \ + && echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \ + && apk add --no-cache --virtual .build-deps \ + dpkg-dev dpkg \ + gcc \ + g++ \ + libc-dev \ + linux-headers \ + make \ + autoconf \ + ncurses-dev \ + openssl-dev \ + unixodbc-dev \ + lksctp-tools-dev \ + tar \ + && export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \ + && mkdir -vp $ERL_TOP \ + && tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 \ + && rm otp-src.tar.gz \ + && ( cd $ERL_TOP \ + && ./otp_build autoconf \ + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ + && ./configure --build="$gnuArch" \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install ) \ + && rm -rf $ERL_TOP \ + && find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf \ + && find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true \ + && find /usr/local -name src | xargs -r find | xargs rmdir -vp || true \ + && scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all \ + && scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \ + && curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \ + && echo "${REBAR3_DOWNLOAD_SHA256} rebar3-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/src/rebar3-src \ + && tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \ + && rm rebar3-src.tar.gz \ + && cd /usr/src/rebar3-src \ + && HOME=$PWD ./bootstrap \ + && install -v ./rebar3 /usr/local/bin/ \ + && rm -rf /usr/src/rebar3-src \ + && apk add --virtual .erlang-rundeps \ + $runDeps \ + lksctp-tools \ + ca-certificates \ + && apk del .fetch-deps .build-deps diff --git a/erlang/22.3.2/alpine/Dockerfile b/erlang/22.3.2/alpine/Dockerfile new file mode 100644 index 0000000..dae96fa --- /dev/null +++ b/erlang/22.3.2/alpine/Dockerfile @@ -0,0 +1,66 @@ +FROM avvo/alpine:3.11 + +# Adapted from: https://github.com/erlang/docker-erlang-otp/blob/master/22/alpine/Dockerfile + +ENV OTP_VERSION="22.3.2" \ + REBAR3_VERSION="3.13.1" + +RUN set -xe \ + && OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \ + && OTP_DOWNLOAD_SHA256="4a3719c71a7998e4f57e73920439b4b1606f7c045e437a0f0f9f1613594d3eaa" \ + && REBAR3_DOWNLOAD_SHA256="706cc0770062bde2674abc01964c68553398fe4d8023605b305cfe326b92520f" \ + && apk add --no-cache --virtual .fetch-deps \ + curl \ + ca-certificates \ + && curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \ + && echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \ + && apk add --no-cache --virtual .build-deps \ + dpkg-dev dpkg \ + gcc \ + g++ \ + libc-dev \ + linux-headers \ + make \ + autoconf \ + ncurses-dev \ + openssl-dev \ + unixodbc-dev \ + lksctp-tools-dev \ + tar \ + && export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \ + && mkdir -vp $ERL_TOP \ + && tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 \ + && rm otp-src.tar.gz \ + && ( cd $ERL_TOP \ + && ./otp_build autoconf \ + && gnuArch="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)" \ + && ./configure --build="$gnuArch" \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install ) \ + && rm -rf $ERL_TOP \ + && find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf \ + && find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true \ + && find /usr/local -name src | xargs -r find | xargs rmdir -vp || true \ + && scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all \ + && scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \ + && curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \ + && echo "${REBAR3_DOWNLOAD_SHA256} rebar3-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/src/rebar3-src \ + && tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \ + && rm rebar3-src.tar.gz \ + && cd /usr/src/rebar3-src \ + && HOME=$PWD ./bootstrap \ + && install -v ./rebar3 /usr/local/bin/ \ + && rm -rf /usr/src/rebar3-src \ + && apk add --virtual .erlang-rundeps \ + $runDeps \ + lksctp-tools \ + ca-certificates \ + && apk del .fetch-deps .build-deps diff --git a/erlang/23.0.2/alpine/Dockerfile b/erlang/23.0.2/alpine/Dockerfile new file mode 100644 index 0000000..82c9e50 --- /dev/null +++ b/erlang/23.0.2/alpine/Dockerfile @@ -0,0 +1,66 @@ +FROM avvo/alpine:3.11 + +# Adapted from: https://github.com/erlang/docker-erlang-otp/blob/master/22/alpine/Dockerfile + +ENV OTP_VERSION="23.0.2" \ + REBAR3_VERSION="3.13.2" + +RUN set -xe \ + && OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \ + && OTP_DOWNLOAD_SHA256="6bab92d1a1b20cc319cd845c23db3611cc99f8c99a610d117578262e3c108af3" \ + && REBAR3_DOWNLOAD_SHA256="e14cdc1f5b7d363a238a9f555f89e878bc4fc836c970571b41b90ee947f91505" \ + && apk add --no-cache --virtual .fetch-deps \ + curl \ + ca-certificates \ + && curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \ + && echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \ + && apk add --no-cache --virtual .build-deps \ + dpkg-dev dpkg \ + gcc \ + g++ \ + libc-dev \ + linux-headers \ + make \ + autoconf \ + ncurses-dev \ + openssl-dev \ + unixodbc-dev \ + lksctp-tools-dev \ + tar \ + && export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \ + && mkdir -vp $ERL_TOP \ + && tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 \ + && rm otp-src.tar.gz \ + && ( cd $ERL_TOP \ + && ./otp_build autoconf \ + && gnuArch="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)" \ + && ./configure --build="$gnuArch" \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install ) \ + && rm -rf $ERL_TOP \ + && find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf \ + && find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true \ + && find /usr/local -name src | xargs -r find | xargs rmdir -vp || true \ + && scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all \ + && scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \ + && curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \ + && echo "${REBAR3_DOWNLOAD_SHA256} rebar3-src.tar.gz" | sha256sum -c - \ + && mkdir -p /usr/src/rebar3-src \ + && tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \ + && rm rebar3-src.tar.gz \ + && cd /usr/src/rebar3-src \ + && HOME=$PWD ./bootstrap \ + && install -v ./rebar3 /usr/local/bin/ \ + && rm -rf /usr/src/rebar3-src \ + && apk add --virtual .erlang-rundeps \ + $runDeps \ + lksctp-tools \ + ca-certificates \ + && apk del .fetch-deps .build-deps diff --git a/push.sh b/push.sh index 6fa5996..d60ca10 100755 --- a/push.sh +++ b/push.sh @@ -1,12 +1,22 @@ #!/usr/bin/env bash set -xe -IMAGE="avvo/$(basename $(dirname $(pwd)))" -TAG="$(basename $(pwd))" +IMAGE="avvo/$(basename $(dirname $(dirname $(pwd))))" +VERSION="$(basename $(dirname $(pwd)))" +BASE="$(basename $(pwd))" +TAG="${VERSION}-${BASE}" +LATEST_TAG="latest" + if [ -n "${1}" ]; then TAG="${TAG}-${1}" fi -docker build -t "${IMAGE}:${TAG}" -t "${IMAGE}:latest" . +if [ "${IMAGE}" == "avvo/elixir-release" ]; then + LATEST_TAG="${LATEST_TAG}-${VERSION}" +else + LATEST_TAG="${LATEST_TAG}-${BASE}" +fi + +docker build -t "${IMAGE}:${TAG}" -t "${IMAGE}:${LATEST_TAG}" . docker push "${IMAGE}:${TAG}" -docker push "${IMAGE}:latest" +docker push "${IMAGE}:${LATEST_TAG}"