Composition
- Jenkins server on EC2 instance, uses EFS
- Docker image for above Jenkins server
Need
- Write templates to directory on EFS each time ECS starts the task which builds the Jenkins server
Where is the appropriate place to put a step to do the write?
Tried
If I do it in the Dockerfile, it writes to the Docker image, but never propagates the changes to EFS so that the templates are available as projects on the Jenkins server.
I've tried putting the write command in jenkins.sh
but I can't figure out how that is run, anyway it doesn't place the templates where I need them.
You need to start the task with a volume, then mount that volume into the container. This way you have persistent storage across multiple Jenkins start/stop cycles.
Your task definition would look something like the below (I've removed the non relevant parts). The important components are
mountPoints
andvolumes
. Not that this is not the same asvolumesFrom
as you aren't mounting volumes from another container, but rather running them in a single task.This also assumes you're running Jenkins in the default
JENKINS_HOME
directory as well as having mounted your EFS drive to/mnt/efs/jenkins-home
on the EC2 instance.Task definition within ECS: