Closed silvio closed 7 years ago
Hi there. Sorry for the late response. I took a personal leave recently. However, I failed to recreate your issue. Here's what I did.
docker run \
--name gerrit \
-p 8080:8080 \
-p 29418:29418 \
-e AUTH_TYPE=DEVELOPMENT_BECOME_ANY_ACCOUNT \
-d openfrontier/gerrit
~$ docker exec gerrit ls -a /var/gerrit/
.
..
.gerritcodereview
bcpkix-jdk15on-1.54.jar
bcprov-jdk15on-1.54.jar
delete-project.jar
events-log.jar
gerrit-oauth-provider.jar
gerrit.war
review_site
As you can see, there's no /.ssh
directory.
Then I accessed the gerrit web page which was exported at 8080 port.
I clicked the "become" menu on the upper right side of the page then chose the "Administrator" link and I could login as the administrator without any problem.
Then I executed docker exec gerrit ls -a /var/gerrit/
again and still no .ssh
directory under /var/gerrit
So can you give me some hints?
The problem is more that I need to rely on precreated ssh keys. I writing an gerrit cli app in rust and want to test my code via your very good docker image. I setup my testenvironment via this script and have patched your sources to initialize the GERRIT_HOME with these predefined keys.
I checked your project.
start_gerrit() { docker run -h localhost -d \ --name gerritlatesttest \ -v ${SITE}:/var/gerrit/review_site \
It might not be a good idea to mount any non-empty directory. As you've already known that it will break the init process.
-e AUTH_TYPE=DEVELOPMENT_BECOME_ANY_ACCOUNT \ -e GERRIT_INIT_ARGS='--install-plugin=download-commands' \ -p 8080:8080 -p 29418:29418 \ "${DOCKERIMAGE}" > /dev/null echo -n "D"
}
Here's my proposal. Move these lines to a separate file such as gen-sshkey.sh. Make sure it has the execute permission.
mkdir -p ${SITE}/.ssh chmod -R go-rwx ${SITE}/.ssh ssh-keygen -t rsa -N "" -f ${SITE}/.ssh/id_rsa
Change docker run command like this. startgerrit() { docker run -h localhost -d \ --name gerritlatesttest \ -v ${SCRIPT_DIR}/gen-sshkey.sh:/docker-entrypoint-init.d/gen-sshkey.sh_ -v ${SITE}:/var/gerrit/review_site \ -e AUTH_TYPE=DEVELOPMENT_BECOME_ANY_ACCOUNT \ -e GERRIT_INIT_ARGS='--install-plugin=download-commands' \ -p 8080:8080 -p 29418:29418 \ "${DOCKERIMAGE}" > /dev/null echo -n "D" }
The Gerrit docker will execute gen-sshkey.sh for you after the first time init.
Thanks - your suggestions point me to the right direction. I have adapted my script.
With AUTH_TYPE=DEVELOPMENT_BECOME_ANY_ACCOUNT gerrit creates an admin user. gerrit is using an existing $HOME/.ssh/id_rsa.pub file to setup the admin user with a ssh key.
A pre created .ssh folder prevents the current version of gerrit-entrypoint.sh to start gerrit in init mode.
Signed-off-by: Silvio Fricke silvio.fricke@gmail.com