I’m in the process of setting up a Jenkins Controller - Worker configuration, and I want to make it easy to understand and maintain the setup. Thus, I’m trying to setup the Controller in a Docker container, have the plugins installed from a list in a text file, and have the configuration of everything handled through the Configuration as Code plugin.
So far, so good. I start with the jenkins/jenkins:lts-jdk11 image, bring my Configuration as Code files into the container and hook them up, and use jenkins-plugin-cli to install plugins. No prob.
However, I want to mount the jenkins_home directory to a directory on the machine running the container. This will allow the configuration to exist across container runs, and it is easier to target that one directory for backup. HOWEVER, because the plugins directory must be in jenkins_home, and because external volumes can’t be mounted during docker’s (or podman’s) build stage, I can’t mount an external jenkins_home directory and fill it with the plugins during the build phase.
Does anyone have experience with putting jenkins_home in an external volume/directory, and is willing to point me in the direction of best practices when putting together the Dockerfile?
Thanks!