Merge branch 'stable-2.14' into stable-2.15 * stable-2.14: Docker: Allow init to write HA plugin config file Docker: Support optional non-default gerrit userid Docker: Use CI archive as 2.14 is no longer built Keep using the CI archive for this branch, as 2.15 is no longer built. Configure the plugin-manager plugin's jenkinsUrl accordingly. Such configuration is not supported in the stable-2.14 branch; gerrit-ci (non-archive) is hardcoded there. However, tolerate the exception thrown at runtime as plugin-manager tries to use a currently non-existing Jenkins view [1]. The latter should be configured soon though, similarly with [2], which 2.14 was also EOL'ed earlier. [1] http://archive-ci.gerritforge.com/view/Plugins-stable-2.15/ [2] http://archive-ci.gerritforge.com/view/Plugins-stable-2.14/ Change-Id: I8bf808df47e0db7fb5889cca747dff1e0cdd19e5
diff --git a/src/test/docker/README.md b/src/test/docker/README.md index fd6818a..68030ae 100644 --- a/src/test/docker/README.md +++ b/src/test/docker/README.md
@@ -12,6 +12,25 @@ $ docker-compose build ``` +### Building the Docker VMs using a non-default user id + +``` + $ export GERRIT_UID=$(id -u) + $ docker-compose build --build-arg GERRIT_UID +``` + +Above, exporting that UID is optional and will be 1000 by default. +Build the gerrit images this way only if the user with id 1000 on your +host is not owned by you. For example, some corporate environments use a +restricted 1000 user (id). In that case, the containerized application +may fail to write towards the host (through volumes). + +That UID will be the one set for the containerized gerrit user. Latter's +group will remain as default (1000). This is because groups known from +the host need to be redefined for containers. Setting that user's group +in the container is not necessary for writing anyway, as opposed to its +user id. The individual gerrit user's writing permission does suffice. + ## How to run Use the 'up' target to startup the Docker Compose VMs.
diff --git a/src/test/docker/docker-compose.yaml b/src/test/docker/docker-compose.yaml index 6ea2438..93971b3 100644 --- a/src/test/docker/docker-compose.yaml +++ b/src/test/docker/docker-compose.yaml
@@ -1,4 +1,4 @@ -version: '2' +version: '3' services: @@ -27,7 +27,7 @@ - ./gitvolume:/var/gerrit/git - ./shareddir:/var/gerrit/shared/dir - ./etc/gerrit.config:/var/gerrit/etc/gerrit.config.orig - - ./etc/high-availability.gerrit-01.config:/var/gerrit/etc/high-availability.config + - ./etc/high-availability.gerrit-01.config:/var/gerrit/etc/high-availability.config.orig environment: - HOSTNAME=localhost @@ -46,7 +46,7 @@ - ./gitvolume:/var/gerrit/git - ./shareddir:/var/gerrit/shared/dir - ./etc/gerrit.config:/var/gerrit/etc/gerrit.config.orig - - ./etc/high-availability.gerrit-01.config:/var/gerrit/etc/high-availability.config + - ./etc/high-availability.gerrit-02.config:/var/gerrit/etc/high-availability.config.orig environment: - HOSTNAME=localhost - WAIT_FOR=gerrit-01:8080 @@ -58,7 +58,7 @@ - "29418:29418" networks: - gerrit-net - volumes_from: + volumes: - syslog-sidecar depends_on: - gerrit-01 @@ -72,3 +72,6 @@ networks: gerrit-net: driver: bridge + +volumes: + syslog-sidecar:
diff --git a/src/test/docker/etc/gerrit.config b/src/test/docker/etc/gerrit.config index c110835..f7ee7ec 100644 --- a/src/test/docker/etc/gerrit.config +++ b/src/test/docker/etc/gerrit.config
@@ -27,3 +27,5 @@ scheme = http scheme = ssh scheme = anon_http +[plugin "plugin-manager"] + jenkinsUrl = https://archive-ci.gerritforge.com
diff --git a/src/test/docker/gerrit/Dockerfile b/src/test/docker/gerrit/Dockerfile index 2d21107..2580e96 100644 --- a/src/test/docker/gerrit/Dockerfile +++ b/src/test/docker/gerrit/Dockerfile
@@ -2,7 +2,7 @@ ENV GERRIT_BRANCH=stable-2.15 -ENV GERRIT_CI_URL=https://gerrit-ci.gerritforge.com/job +ENV GERRIT_CI_URL=https://archive-ci.gerritforge.com/job USER root @@ -21,4 +21,6 @@ RUN rm -Rf /var/gerrit/{git,index,cache}/* +ARG GERRIT_UID=1000 +RUN usermod -u ${GERRIT_UID} gerrit &> /dev/null CMD /bin/start.sh
diff --git a/src/test/docker/gerrit/start.sh b/src/test/docker/gerrit/start.sh index 51bc9bc..8666485 100755 --- a/src/test/docker/gerrit/start.sh +++ b/src/test/docker/gerrit/start.sh
@@ -7,7 +7,10 @@ wait-for-it.sh $WAIT_FOR -t 600 -- echo "$WAIT_FOR is up" fi +chown -R gerrit: /var/gerrit + sudo -u gerrit cp /var/gerrit/etc/gerrit.config.orig /var/gerrit/etc/gerrit.config +sudo -u gerrit cp /var/gerrit/etc/high-availability.config.orig /var/gerrit/etc/high-availability.config if [[ ! -f /var/gerrit/git/All-Projects.git/config ]] then @@ -19,7 +22,7 @@ sudo -u gerrit java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit sudo -u gerrit git config -f /var/gerrit/etc/gerrit.config gerrit.canonicalWebUrl http://$HOSTNAME/ -touch /var/gerrit/logs/{gc_log,error_log,httpd_log,sshd_log,replication_log} && chown -R gerrit: /var/gerrit && tail -f /var/gerrit/logs/* | grep --line-buffered -v 'HEAD /' & +touch /var/gerrit/logs/{gc_log,error_log,httpd_log,sshd_log,replication_log} && tail -f /var/gerrit/logs/* | grep --line-buffered -v 'HEAD /' & echo "Running Gerrit ..." sudo -u gerrit /etc/init.d/gerrit run