Create Gerrit-user in base-image

All images based on the base-container image use the Gerrit user. So far
this user was created in downstream images. This change moves the user
creation to the base image, reducing code duplication.

Change-Id: I904d70caff854ee99cf2de76eb0942465f38b5cb
diff --git a/container-images/apache-git-http-backend/Dockerfile b/container-images/apache-git-http-backend/Dockerfile
index c5d39b7..6cac131 100644
--- a/container-images/apache-git-http-backend/Dockerfile
+++ b/container-images/apache-git-http-backend/Dockerfile
@@ -33,9 +33,6 @@
 EXPOSE 80
 EXPOSE 443
 
-ARG GERRIT_UID=1000
-RUN useradd gerrit -u $GERRIT_UID -g users
-
 VOLUME ["/var/gerrit/git", "/var/apache/credentials", "/var/log/apache2"]
 
 # Start
diff --git a/container-images/apache-git-http-backend/README.md b/container-images/apache-git-http-backend/README.md
index 980fc80..67df3ed 100644
--- a/container-images/apache-git-http-backend/README.md
+++ b/container-images/apache-git-http-backend/README.md
@@ -26,7 +26,6 @@
 * configure Apache for http and/or https
 * install cgi script
 * open ports for incoming traffic
-* create gerrit OS user
 * map volumes
 
 ## Start
@@ -36,4 +35,4 @@
  It is used to set the filesystem group of mounted volumes to 100 (users),
  which is used by the gerrit-user in the containers. Thereby it is ensured
  that the volumes have rw-permissions for the gerrit-user.
-* start Apache git-http backend  via start script `/var/tools/start`
\ No newline at end of file
+* start Apache git-http backend  via start script `/var/tools/start`
diff --git a/container-images/base/Dockerfile b/container-images/base/Dockerfile
index 3e43e6f..b2481d3 100644
--- a/container-images/base/Dockerfile
+++ b/container-images/base/Dockerfile
@@ -8,4 +8,7 @@
     apt-get clean && \
     rm -rf /var/lib/apt/lists/*
 
+ARG GERRIT_UID=1000
+RUN useradd gerrit -u $GERRIT_UID -g users
+
 COPY tools/* /var/tools/
diff --git a/container-images/base/README.md b/container-images/base/README.md
index ea48c39..c409505 100644
--- a/container-images/base/README.md
+++ b/container-images/base/README.md
@@ -8,5 +8,6 @@
 * Ubuntu 18.04
 * git
 * openssh client
+* create `gerrit`-user as a non-root user to run the applications
 * `tools/validate_site.sh`: validates Gerrit site directory and ensures
- filesystem permissions for gerrit user are correct
\ No newline at end of file
+ filesystem permissions for gerrit user are correct
diff --git a/container-images/gerrit-base/Dockerfile b/container-images/gerrit-base/Dockerfile
index a8c682c..54aa13f 100644
--- a/container-images/gerrit-base/Dockerfile
+++ b/container-images/gerrit-base/Dockerfile
@@ -16,9 +16,6 @@
 ARG GERRIT_WAR_URL=https://gerrit-ci.gerritforge.com/view/Gerrit/job/Gerrit-bazel-stable-2.16/lastSuccessfulBuild/artifact/gerrit/bazel-bin/release.war
 RUN curl -k -o /var/war/gerrit.war ${GERRIT_WAR_URL} && ln -s /var/war/gerrit.war /var/gerrit/bin/gerrit.war
 
-ARG GERRIT_UID=1000
-RUN useradd gerrit -u $GERRIT_UID -g users
-
 # Allow incoming traffic
 EXPOSE 29418 8080
 
diff --git a/container-images/gerrit-base/README.md b/container-images/gerrit-base/README.md
index 9a9d83f..ba53cdb 100644
--- a/container-images/gerrit-base/README.md
+++ b/container-images/gerrit-base/README.md
@@ -12,11 +12,10 @@
 ## Setup and configuration
 
 * create base folders for gerrit binary and gerrit configuration
-* create gerrit OS user
 * download gerrit.war from provided URL
 * prepare filesystem permissions for gerrit user
 * open ports for incoming traffic
 
 ## Start
 
-* starts the container via start script `/var/tools/start`
\ No newline at end of file
+* starts the container via start script `/var/tools/start`
diff --git a/container-images/git-gc/Dockerfile b/container-images/git-gc/Dockerfile
index e92bec8..f72b53b 100644
--- a/container-images/git-gc/Dockerfile
+++ b/container-images/git-gc/Dockerfile
@@ -10,9 +10,7 @@
 COPY tools/* /var/tools/
 COPY cron/* /var/cron/
 
-ARG GERRIT_UID=1000
-RUN useradd gerrit -u $GERRIT_UID -g users && \
-    mkdir -p /var/log/git && \
+RUN mkdir -p /var/log/git && \
     chown gerrit:users /var/log/git
 
 VOLUME ["/var/gerrit/git"]
diff --git a/container-images/git-gc/README.md b/container-images/git-gc/README.md
index 108d860..b573651 100644
--- a/container-images/git-gc/README.md
+++ b/container-images/git-gc/README.md
@@ -16,7 +16,6 @@
 * install cron
 * copy tools scripts
 * install crontab
-* create gerrit OS user
 * ensure filesystem permissions
 
 ## Start
@@ -26,4 +25,4 @@
 The start script
 
 * starts cron which schedules the execution of the provided `gc-all.sh`
-* ensures file system permissions
\ No newline at end of file
+* ensures file system permissions