Fixed Website bot to work with docker user namespaces.

ASF CI has enabled user namespaces for docker daemon on the build
machines that are used to build the website. This commit makes the
requisite changes to work with user namespacing.

Review: https://reviews.apache.org/r/72856
diff --git a/support/mesos-website.sh b/support/mesos-website.sh
index 04a6646..af98f36 100755
--- a/support/mesos-website.sh
+++ b/support/mesos-website.sh
@@ -32,15 +32,11 @@
 
 trap 'docker rmi $TAG' EXIT
 
-# NOTE: We set `LOCAL_USER_ID` environment variable to enable running the
-# container process with the same UID as the user running this script. This
-# ensures that any writes to the mounted volumes will have the same permissions
-# as the user running the script, making it easy to do cleanups; otherwise
-# any writes will have permissions of UID 0 by default on Linux.
-
+# NOTE: ASF CI remaps the host `jenkins` user to UID 0 inside the container
+# so we don't need to do any user switching inside the container to be able
+# to write to the mounted host volumes with the correct permissions.
 docker run \
   --rm \
-  -e LOCAL_USER_ID="$(id -u "$USER")" \
   -v "$MESOS_DIR":/mesos:Z \
   -v "$MESOS_SITE_DIR/content":/mesos/site/publish:Z \
   $TAG
diff --git a/support/mesos-website/Dockerfile b/support/mesos-website/Dockerfile
index 611c496..bcd62fe 100644
--- a/support/mesos-website/Dockerfile
+++ b/support/mesos-website/Dockerfile
@@ -3,8 +3,10 @@
 
 LABEL Description="This image is used for generating Mesos web site."
 
-# The mesos build image drops down to user `mesos`, but
-# we need priviledged access to install packages below.
+# Set the root user explicitly because the base image
+# `mesos/mesos-build` uses `mesos` user by default. Also, note that
+# `root` inside the container is mapped to `jenkins` user on the build
+# machine host in ASF CI.
 USER root
 
 # Install dependencies.
diff --git a/support/mesos-website/build.sh b/support/mesos-website/build.sh
index afbec48..45ab892 100755
--- a/support/mesos-website/build.sh
+++ b/support/mesos-website/build.sh
@@ -27,6 +27,19 @@
 
 trap exit_hook EXIT
 
+file_owner_uid=`stat . --format=%u`
+current_user_uid=`id -u`
+if [ $file_owner_uid -ne $current_user_uid ];
+then
+  echo "
+    The mounted mesos sources are owned by UID $file_owner_uid
+    which is different from the current user UID $current_user_uid
+    inside the container. Please check that dockerd has
+    user namespace remapping configured properly.
+  "
+  exit 1
+fi
+
 # Build mesos to get the latest master and agent binaries.
 ./bootstrap
 mkdir -p build
diff --git a/support/mesos-website/entrypoint.sh b/support/mesos-website/entrypoint.sh
index 72fd723..2029949 100755
--- a/support/mesos-website/entrypoint.sh
+++ b/support/mesos-website/entrypoint.sh
@@ -16,18 +16,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# This is a wrapper script for building Mesos website as a non-root user.
+# This is a wrapper script for building Mesos website.
+# TODO(vinod): Merge this with `build.sh` now that we dont need to switch
+# users in ASF CI as user namespacing has been implemented.
 set -e
 set -o pipefail
 
-# This needs to be run under `root` user for `bundle exec rake` to
-# work properly. See MESOS-7859.
 pushd site
 bundle install
 popd # site
 
-# Create a local user account.
-useradd -u $LOCAL_USER_ID -s /bin/bash -m tempuser
-
-# Build mesos and the website as the new user.
-su -c support/mesos-website/build.sh tempuser
+./support/mesos-website/build.sh