THRIFT-5755 Docker image build fail

This PR submits fixes to the focal and jammy docker images.

* Bionic support was dropped becaused dotnet 8 no longer supports bionic
(Ubuntu 18.04). Moved to `old/` like other unmaintained images.
* Focal/Jammy used the wrong apt location for dotnet, endpoint was 18.04
  instead of 20.04/22.04
* Jammy cannot build Erlang OPT 23 since it depends on OpenSSL 1.1
  which was dropped in favor of 3.0. Using Erlang OPT 25 fixes the
  problem since it depends on OpenSSL 3.0
* Jammy was installing JDK 11 but lib/java requires Java 17

All containers used the `root` used to volume map the local files into
the running container. This creates a hard to maintain working directory
on Linux and MacOS since files form the local user and root user are
mixed.
To solve this the new docker files can be build using the UID and GID of
the host so the files dont mix. The script uses UID and GID 1000 since
these are the default ids for most Linux distros.

Change the travis yml to build with 20.04 instead of 18.04. Removed all
traces of 18.04 but it cant be tested locally.

Updated the README to reflect the new `build/docker/` directory.
diff --git a/.travis.yml b/.travis.yml
index b771d70..99dd2bc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,7 +47,7 @@
     - SCRIPT="cmake.sh"
     - BUILD_ARG=""
     - BUILD_ENV="-e CC=gcc -e CXX=g++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
-    - DISTRO=ubuntu-bionic
+    - DISTRO=ubuntu-focal
     - BUILD_LIBS="CPP C_GLIB JAVA PYTHON TESTING TUTORIALS"  # only meaningful for CMake builds
     - TRAVIS_BUILD_STAGE=test
     # DOCKER_REPO (this works for all builds as a source for docker images - you can override for fork builds in your Travis settings)
@@ -58,12 +58,6 @@
 jobs:
   include:
     # ========================= stage: docker =========================
-    - stage: docker
-      script: true
-      env:
-        - JOB="Docker Build ubuntu-bionic 18.04 LTS"
-        - DISTRO=ubuntu-bionic
-        - TRAVIS_BUILD_STAGE=docker
     - script: true
       env:
         - JOB="Docker Build ubuntu-focal 20.04 LTS"
@@ -131,12 +125,6 @@
         - DISTRO=ubuntu-focal
         - SCRIPT="autotools.sh"
 
-    - script: build/docker/run.sh
-      env:
-        - JOB="Autotools (Ubuntu Bionic)"
-        - DISTRO=ubuntu-bionic
-        - SCRIPT="autotools.sh"
-
     # ------------------------- phase: cmake ------------------------
     - script: build/docker/run.sh
       env:
diff --git a/build/docker/README.md b/build/docker/README.md
index 9c9175f..3cb1a32 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -20,12 +20,12 @@
 
 | Variable | Default | Usage |
 | -------- | ----- | ------- |
-| `DISTRO` | `ubuntu-bionic` | Set by various build jobs in `.travis.yml` to run builds in different containers.  Not intended to be set externally.|
+| `DISTRO` | `ubuntu-focal` | Set by various build jobs in `.travis.yml` to run builds in different containers.  Not intended to be set externally.|
 | `DOCKER_REPO` | `thrift/thrift-build` | The name of the Docker Hub repository to obtain and store docker images. |
 | `DOCKER_USER` | `<none>` | The Docker Hub account name containing the repository. |
 | `DOCKER_PASS` | `<none>` | The Docker Hub account password to use when pushing new tags. |
 
-For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-bionic`
+For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-focal`
 
 ### Forks ###
 
@@ -46,14 +46,13 @@
 
 ## Supported Containers ##
 
-The Travis CI (continuous integration) builds use the Ubuntu Bionic
-(18.04 LTS) and Xenial (16.04 LTS) images to maximize language level
+The Travis CI (continuous integration) builds use the Ubuntu Jammy
+(22.04 LTS) and Focal (20.04 LTS) images to maximize language level
 coverage.
 
 ### Ubuntu ###
 
 * focal (stable, current)
-* bionic (previous stable)
 * jammy (next stable, WIP)
 
 ## Unsupported Containers ##
@@ -105,16 +104,16 @@
 Travis CI does it) - if it is out of date in any way it will build a
 new one for you:
 
-    thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-bionic build/docker/refresh.sh
+    thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-focal build/docker/refresh.sh
 
 To run all unit tests (just like Travis CI does):
 
-    thrift$ dockerrun thrift/thrift-build:ubuntu-bionic
+    thrift$ dockerrun thrift/thrift-build:ubuntu-focal
     root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh
 
 To run the cross tests (just like Travis CI does):
 
-    thrift$ dockerrun thrift/thrift-build:ubuntu-bionic
+    thrift$ dockerrun thrift/thrift-build:ubuntu-focal
     root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh
 
 When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space:
@@ -136,7 +135,14 @@
 
 Build the image:
 
-    thrift$ docker build -t thrift build/docker/ubuntu-bionic
+Linux/Mac:
+
+    thrift$ docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g) -t thrift build/docker/ubuntu-jammy
+
+Windows:
+
+    thrift$ docker build -t thrift build/docker/ubuntu-jammy
+
 
 Open a command prompt in the image:
 
diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/old/ubuntu-bionic/Dockerfile
similarity index 93%
rename from build/docker/ubuntu-bionic/Dockerfile
rename to build/docker/old/ubuntu-bionic/Dockerfile
index 5ece6e1..6d337d7 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/old/ubuntu-bionic/Dockerfile
@@ -124,10 +124,10 @@
 
 RUN apt-get install -y --no-install-recommends \
       `# dotnet core dependencies` \
-      dotnet-sdk-8.0 \
-      dotnet-runtime-8.0 \
-      aspnetcore-runtime-8.0 \
-      dotnet-apphost-pack-8.0
+      dotnet-sdk-7.0 \
+      dotnet-runtime-7.0 \
+      aspnetcore-runtime-7.0 \
+      dotnet-apphost-pack-7.0
 
 # Erlang dependencies
 ARG ERLANG_OTP_VERSION=23.3.4.11
@@ -298,7 +298,21 @@
 #     rm -rf /tmp/* && \
 #     rm -rf /var/tmp/*
 
+ARG user=build
+ARG group=build
+ARG uid=1000
+ARG gid=1000
+
+RUN apt-get install -y --no-install-recommends sudo && \
+    echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \
+    if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \
+    adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \
+    echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
 ENV THRIFT_ROOT /thrift
-RUN mkdir -p $THRIFT_ROOT/src
+RUN mkdir -p $THRIFT_ROOT/src && \
+    chown -R ${uid}:${uid} $THRIFT_ROOT/
 COPY Dockerfile $THRIFT_ROOT/
 WORKDIR $THRIFT_ROOT/src
+
+USER ${user}
diff --git a/build/docker/ubuntu-focal/Dockerfile b/build/docker/ubuntu-focal/Dockerfile
index 416e806..00ab2be 100644
--- a/build/docker/ubuntu-focal/Dockerfile
+++ b/build/docker/ubuntu-focal/Dockerfile
@@ -39,7 +39,7 @@
 
 # dotnet (netcore)
 RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \
-      wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \
+      wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/20.04/prod.list && \
       chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \
       chown root:root /etc/apt/sources.list.d/microsoft-prod.list
 
@@ -280,7 +280,21 @@
 #     rm -rf /tmp/* && \
 #     rm -rf /var/tmp/*
 
+ARG user=build
+ARG group=build
+ARG uid=1000
+ARG gid=1000
+
+RUN apt-get install -y --no-install-recommends sudo && \
+    echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \
+    if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \
+    adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \
+    echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
 ENV THRIFT_ROOT /thrift
-RUN mkdir -p $THRIFT_ROOT/src
+RUN mkdir -p $THRIFT_ROOT/src && \
+    chown -R ${uid}:${uid} $THRIFT_ROOT/
 COPY Dockerfile $THRIFT_ROOT/
 WORKDIR $THRIFT_ROOT/src
+
+USER ${user}
diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile
index a10fea6..d214b9f 100644
--- a/build/docker/ubuntu-jammy/Dockerfile
+++ b/build/docker/ubuntu-jammy/Dockerfile
@@ -39,7 +39,7 @@
 
 # dotnet (netcore)
 RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \
-  wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/18.04/prod.list && \
+  wget -q -O /etc/apt/sources.list.d/microsoft-prod.list https://packages.microsoft.com/config/ubuntu/22.04/prod.list && \
   chown root:root /etc/apt/trusted.gpg.d/microsoft.gpg && \
   chown root:root /etc/apt/sources.list.d/microsoft-prod.list
 
@@ -84,7 +84,6 @@
   libboost-all-dev \
   libevent-dev \
   libssl-dev \
-  qt5-default \
   qtbase5-dev \
   qtbase5-dev-tools
 
@@ -131,7 +130,7 @@
   dotnet-apphost-pack-8.0
 
 # Erlang dependencies
-ARG ERLANG_OTP_VERSION=23.3.4.11
+ARG ERLANG_OTP_VERSION=25.3.2.9
 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 && \
@@ -168,7 +167,7 @@
   ant \
   ant-optional \
   maven \
-  openjdk-11-jdk-headless && \
+  openjdk-17-jdk-headless && \
   `# Gradle` \
   wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip && \
   (echo "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae  /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -) && \
@@ -280,7 +279,21 @@
 #     rm -rf /tmp/* && \
 #     rm -rf /var/tmp/*
 
+ARG user=build
+ARG group=build
+ARG uid=1000
+ARG gid=1000
+
+RUN apt-get install -y --no-install-recommends sudo && \
+    echo "Running with: UID: ${uid}, User: ${user}, GID: ${gid}, Group: ${group}" && \
+    if [ -z `cat /etc/group | grep "${group}:"` ]; then addgroup --gid ${gid} ${group}; fi && \
+    adduser --uid ${uid} --gid ${gid} --shell /bin/bash ${user} --disabled-password -q --gecos "" && \
+    echo "${user} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
 ENV THRIFT_ROOT /thrift
-RUN mkdir -p $THRIFT_ROOT/src
+RUN mkdir -p $THRIFT_ROOT/src && \
+    chown -R ${uid}:${uid} $THRIFT_ROOT/
 COPY Dockerfile $THRIFT_ROOT/
 WORKDIR $THRIFT_ROOT/src
+
+USER ${user}