THRIFT-5536 Fix cross language tests
diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile
index 08c45df..0e11d2a 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/ubuntu-bionic/Dockerfile
@@ -43,10 +43,6 @@
     chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \
     chown root:root /etc/apt/sources.list.d/microsoft-prod.list
 
-# erlang
-RUN wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | apt-key add - && \
-    echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | tee /etc/apt/sources.list.d/erlang.list
-
 # node.js
 RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
     echo "deb https://deb.nodesource.com/node_10.x bionic main" | tee /etc/apt/sources.list.d/nodesource.list
@@ -80,6 +76,8 @@
     unzip flex_sdk_4.6.zip
 ENV FLEX_HOME /usr/local/adobe/flex/4.6
 
+# TODO: "apt-get install" without "apt-get update" in the same "RUN" step can cause cache issues if modified later.
+# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
 RUN apt-get install -y --no-install-recommends \
 `# C++ dependencies` \
       libboost-all-dev \
@@ -119,12 +117,15 @@
       aspnetcore-runtime-6.0 \
       dotnet-apphost-pack-6.0
 
-RUN apt-get install -y --no-install-recommends \
-`# Erlang dependencies` \
-      erlang && \
-    wget https://s3.amazonaws.com/rebar3/rebar3 -O /usr/bin/rebar3 && \
-    chmod 755 /usr/bin/rebar3 && \
+# Erlang dependencies
+ARG ERLANG_OTP_VERSION=23.3.4.11
+ARG ERLANG_REBAR_VERSION=3.18.0
+RUN apt-get update && apt-get install -y --no-install-recommends libncurses5-dev && \
+    curl -ssLo /usr/local/bin/kerl https://raw.githubusercontent.com/kerl/kerl/master/kerl && chmod +x /usr/local/bin/kerl && \
+    kerl build $ERLANG_OTP_VERSION && kerl install $ERLANG_OTP_VERSION /usr/local/lib/otp/ && . /usr/local/lib/otp/activate && \
+    curl -ssLo /usr/local/bin/rebar3 https://github.com/erlang/rebar3/releases/download/${ERLANG_REBAR_VERSION}/rebar3 && chmod +x /usr/local/bin/rebar3 && \
     rebar3 --version
+ENV PATH /usr/local/lib/otp/bin:$PATH
 
 RUN apt-get install -y --no-install-recommends \
 `# GlibC dependencies` \
@@ -262,11 +263,12 @@
     dpkg -i cppcheck_1.83-2_amd64.deb && \
     rm cppcheck_1.83-2_amd64.deb
 
-# Clean up
-RUN rm -rf /var/cache/apt/* && \
-    rm -rf /var/lib/apt/lists/* && \
-    rm -rf /tmp/* && \
-    rm -rf /var/tmp/*
+# NOTE: this does not reduce the image size but adds an additional layer.
+# # Clean up
+# RUN rm -rf /var/cache/apt/* && \
+#     rm -rf /var/lib/apt/lists/* && \
+#     rm -rf /tmp/* && \
+#     rm -rf /var/tmp/*
 
 ENV THRIFT_ROOT /thrift
 RUN mkdir -p $THRIFT_ROOT/src