openfrontier / docker-gerrit

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

Provide an existing gerrit.config #106

Open dmitvitalii opened 5 years ago

dmitvitalii commented 5 years ago

In case of migration it would be really useful to have an ability to provide a single gerrit.config file instead of/with providing parameters separately. E.g.

docker run \
  --name gerrit \
  -e GERRIT_CONFIG_FILE=path/to/gerrit.config \ # with all existing configuartions
  -e WEBURL=http://my-gerrit.example.com \ # e.g. if we want different url
  -d openfrontier/gerrit
thinkernel commented 5 years ago

This is an interesting idea. Let me think about it. Basicly, I can add a cp path/to/gerrit.config ${GERRIT_HOME}/review_site/etc in the gerrit-entrypoint.sh somewhere before setting other parameters according to the environment variables. This is not a big deal. On the user's hand, you should mount this file into the container by using docker run -v or ConfigMap in k8s, but on the other hand, is it even better to mount gerrit.config file on the ${GERRIT_HOME}/review_site/etc/gerrit.config directly? I've never done this before, just an idea worth considering.

dmitvitalii commented 5 years ago

For now I came up with something like:

# gerrit-entrypoint.sh
copy_gerrit_config() {
  su-exec ${GERRIT_USER} cp "${1}" "${GERRIT_SITE}/etc/gerrit.config"
}
......
#Copy gerrit.config, replace an existing one
if [ -n "${GERRIT_CONFIG_FILE}" ]; the
  copy_gerrit_config "${GERRIT_CONFIG_FILE}"
fi

and going to test it soon.

There is a drawback:

docker run \
  --name gerrit \
  -e WEBURL=http://my-gerrit.example.com \
  -e GERRIT_CONFIG_FILE=path/to/gerrit.config

will cause an ignoring of previously provided parameters (WEBURI in this case).

UPD: I'ts not gonna work. I wasn't able to access an external FS from gerrit-entrypoint.sh to get a file that way.

thinkernel commented 5 years ago

I added some commends in your commit. Would you please check it there?

dmitvitalii commented 5 years ago

Thank you for comments! Will check them.