openfrontier / docker-gerrit

Build a Docker image with the Gerrit code review system
Apache License 2.0
197 stars 116 forks source link

Create missing directories when using volume #26

Closed fpytloun closed 7 years ago

thinkernel commented 8 years ago

Could you show me your docker run command line? I wonder in which circumstance the init command can't create these sub directories.

fpytloun commented 8 years ago

I am starting gerrit using compose file like this:

version: '2'
services:
  gerrit_master:
    image: tcpcloud/gerrit:2.13
    restart: on-failure
    ports: ['8080:8080', '29418:29418']
    volumes: ['/srv/volumes/gerrit:/var/gerrit/review_site']
    env_file: .env

The important part is volume which is probably why I hit this issue.

thinkernel commented 8 years ago

I failed to recreate your problem by using my Gerrit image which is openfrontier/gerrit:latest. Instead of using docker compose, I tried the docker run command to mount an empty local directory as a volume and everything looks OK. I don't think you need to create the etc & lib & plugins directories by yourself. The java -jar "${GERRIT_WAR}" init command will create them for you with the right ownership. In fact, I tried to use your image to start up a gerrit and I found that the ownership of etc & lib & plugins became root. That's why you would have to reindex gerrit and fix this problem in your second patch.

hasufell commented 8 years ago

I guess I have a similar problem when mounting in a local directory:

irst time initialize gerrit...
[2016-10-02 18:58:42,565] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /var/gerrit/review_site/etc/gerrit.config; assuming defaults
Cannot find plugin(s): oauth-authentication-provider
Available plugins:
 * commit-message-length-validator version v2.12.5
 * download-commands version v2.12.5
 * replication version v2.12.5
 * reviewnotes version v2.12.5
 * singleusergroup version v2.12.5
cp: can't create '/var/gerrit/review_site/plugins/delete-project.jar': No such file or directory
thinkernel commented 8 years ago

@hasufell I figure out the problem. I forgot to use gosu to copy plugin jars into the volume that means those jars were copied with root ownership. This will cause problems when the volume are located in your local directory. I fixed this bug and build new images with tags of latest, 2.12.5, 2.11.x, 2.11.10. Please pull one of those images and tell my the result.