Startup scripts and plugins missing in 3.0.0rc1 docker image

134 views
Skip to first unread message

Peter Bruin

unread,
May 2, 2019, 5:14:31 AM5/2/19
to Repo and Gerrit Discussion
I noticed that the startup scripts and plugins are not present in the latest docker image.
These are normally installed during the building of the image.

This is what is in the 2.16.8 image:
RUN java -jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/gerrit && java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit && git config -f /var/gerrit/etc/gerrit.config --add container.javaOptions "-Djava.security.egd=file:/dev/./urandom"

And this is the 3,0.0rc1 image
RUN git config -f /var/gerrit/etc/gerrit.config --add container.javaOptions "-Djava.security.egd=file:/dev/./urandom"

When I run the command in my docker-compose as part of the upgrade the installation will be upgraded but as the bin and plugin folder are not mapped the data will be lost during the next startup of the container.

I added the RUN java -jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/gerrit  to my local Dockerfile and that makes it work.

I am wondering if this change was on purpose or if I need to do something else during the initialization of the docker installation.

Thanks,
Peter Bruin

Luca Milanesio

unread,
May 2, 2019, 5:47:45 AM5/2/19
to Peter Bruin, Luca Milanesio, Repo and Gerrit Discussion

On 2 May 2019, at 10:14, Peter Bruin <peterb...@gmail.com> wrote:

I noticed that the startup scripts and plugins are not present in the latest docker image.
These are normally installed during the building of the image.

I tried now and it works for me: see my output at http://paste.openstack.org/show/750156/


This is what is in the 2.16.8 image:
RUN java -jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/gerrit && java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit && git config -f /var/gerrit/etc/gerrit.config --add container.javaOptions "-Djava.security.egd=file:/dev/./urandom"

And this is the 3,0.0rc1 image
RUN git config -f /var/gerrit/etc/gerrit.config --add container.javaOptions "-Djava.security.egd=file:/dev/./urandom"

Yes, the init and startup are moved to the entrypoint.


When I run the command in my docker-compose as part of the upgrade the installation will be upgraded but as the bin and plugin folder are not mapped the data will be lost during the next startup of the container.

/bin and /plugin shouldn't be mapped externally, are party of the distribution and *not* part of the Gerrit site data.


I added the RUN java -jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/gerrit  to my local Dockerfile and that makes it work.

Why don't you just use the standard entrypoint?


I am wondering if this change was on purpose or if I need to do something else during the initialization of the docker installation.

Can you share your docker compose YAML file?

The purpose was twofold:
a) Not assuming anymore that the Docker image contains a pre-initialised site, that would just use more space in the image and wouldn't work for externally mounted gerrit sites.
b) Gerrit 3.0 doesn't have a pre-defined '/db' directory anymore, however it gets created during the init as 'root' and it wouldn't allow gerrit to start afterwards.

The change was documented in the 3.0 release notes:

Does this help?

Luca.

Peter Bruin

unread,
May 2, 2019, 8:41:16 AM5/2/19
to Repo and Gerrit Discussion
This is my docker-compose file for my 3.0 test site, hence the odd port numbers.
 
version: '3.4'


services
:
  gerrit
:
    build
: .
    ports
:
     
- "29419:29419"
     
- "8082:8082"
   
#restart: unless-stopped
    volumes
:
     
- /external/gerrit3.0/etc:/var/gerrit/etc
     
- /external/gerrit3.0/git:/var/gerrit/git
     
- /external/gerrit3.0/index:/var/gerrit/index
     
- /external/gerrit3.0/cache:/var/gerrit/cache
     
- /external/gerrit3.0/logs:/var/gerrit/logs
     
- /external/gerrit3.0/.ssh:/var/gerrit/.ssh


networks
:
 
default:
    ipam
:
      driver
: default
      config
:
       
- subnet: 172.29.1.0/24



This is my custom Dockerfile that adds an additional plugins, hooks and static content (logo).
------------
FROM gerritcodereview/gerrit:3.0.0-rc1
COPY
./plugins/* /var/gerrit/plugins/
COPY ./static/* /var/gerrit/static/
COPY ./hooks/* /var/gerrit/hooks/

ENV CANONICAL_WEB_URL=https://gerrit.my_domain.net/r3/


Output when running docker-compose up:


Creating network "30_default" with the default driver
Creating 30_gerrit_1 ...
Creating 30_gerrit_1 ... done
Attaching to 30_gerrit_1
gerrit_1  
| Running Gerrit ...
gerrit_1  
| /entrypoint.sh: line 13: /var/gerrit/bin/gerrit.sh: No such file or directory
30_gerrit_1 exited with code 1


Peter Bruin

unread,
May 2, 2019, 8:49:01 AM5/2/19
to Repo and Gerrit Discussion
Hi Luca,

I just had a look at the entrypoint.sh script and it looks like the entrypoint.sh script works fine for new sites but will not work for existing sites as the All-Projects.git already exists. 

I think the original way of doing it was fine as it would create a default configuration in the image and populate the plugin and bin folder. However, this is now not done for existing sites and they will not be able to start.
Best Regards,
Peter Bruin

#!/bin/bash -e


if [ ! -d /var/gerrit/git/All-Projects.git ]
then
  echo
"Initializing Gerrit site ..."

  java
-jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/
gerrit
  java
-jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit
fi


git config
-f /var/gerrit/etc/gerrit.config gerrit.canonicalWebUrl "${CANONICAL_WEB_URL:-http://$HOSTNAME}"


echo
"Running Gerrit ..."
exec /var/gerrit/bin/gerrit.sh run



Luca Milanesio

unread,
May 9, 2019, 9:53:04 AM5/9/19
to Peter Bruin, Luca Milanesio, Repo and Gerrit Discussion

On 2 May 2019, at 13:49, Peter Bruin <peterb...@gmail.com> wrote:

Hi Luca,

I just had a look at the entrypoint.sh script and it looks like the entrypoint.sh script works fine for new sites but will not work for existing sites as the All-Projects.git already exists. 

I think the original way of doing it was fine as it would create a default configuration in the image and populate the plugin and bin folder. However, this is now not done for existing sites and they will not be able to start.

Oh yes, this is because the run of the init step is done *ONLY* if the All-Projects.git doesn't exist.
Let address this and I will fix it before the 3.0.0-rc3 packaging for Docker.

Thanks again for your feedback.

Luca.

Best Regards,
Peter Bruin

#!/bin/bash -e


if [ ! -d /var/gerrit/git/All-Projects.git ]
then
  echo
"Initializing Gerrit site ..."
  java
-jar /var/gerrit/bin/gerrit.war init --batch --install-all-plugins -d /var/gerrit
  java
-jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit
fi


git config
-f /var/gerrit/etc/gerrit.config gerrit.canonicalWebUrl "${CANONICAL_WEB_URL:-http://$HOSTNAME}"


echo
"Running Gerrit ..."
exec /var/gerrit/bin/gerrit.sh run




--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luca Milanesio

unread,
May 9, 2019, 12:20:33 PM5/9/19
to Peter Bruin, Luca Milanesio, Repo and Gerrit Discussion

On 9 May 2019, at 14:52, Luca Milanesio <luca.mi...@gmail.com> wrote:



On 2 May 2019, at 13:49, Peter Bruin <peterb...@gmail.com> wrote:

Hi Luca,

I just had a look at the entrypoint.sh script and it looks like the entrypoint.sh script works fine for new sites but will not work for existing sites as the All-Projects.git already exists. 

I think the original way of doing it was fine as it would create a default configuration in the image and populate the plugin and bin folder. However, this is now not done for existing sites and they will not be able to start.

Oh yes, this is because the run of the init step is done *ONLY* if the All-Projects.git doesn't exist.
Let address this and I will fix it before the 3.0.0-rc3 packaging for Docker.

I've created a fix on:

Can you have a look and check if that would work for you?
I tested locally and it works fine for me, including the upgrade from v2.16.

Luca.

Peter Bruin

unread,
May 12, 2019, 8:40:07 PM5/12/19
to Repo and Gerrit Discussion
Hi Luca,

Sorry for the late reply.
I have tested the latest 3.0.0-rc3 image and it is all working fine now.

Thanks for your support.
Peter
Reply all
Reply to author
Forward
0 new messages