Reputation: 149
So I want to start using Jenkins to build my app and then test it and push my image to local repo. Because I have 2 images to push I would like to use docker-compose, but docker-compose is missing.
I installed Jenkins through Portainer, and I'm using the jenkins/jenkins:lts image.
Is there a way to install docker-compose into the container without having to create my own Dockerfile for it?
My Jenkins pipeline so far is:
node {
stage('Clone repository') {
checkout([$class: 'GitSCM',
branches: [[name: '*/master' ]],
extensions: scm.extensions,
userRemoteConfigs: [[
url: 'repo-link',
credentialsId: 'credentials'
]]
])
}
stage('Build image') {
sh 'cd src/ && docker-compose build'
}
stage('Push image') {
sh 'docker-compose push'
}
}
Upvotes: 3
Views: 2799
Reputation: 578
You can either install docker-compose during image build time (via Dockerfile):
FROM jenkins/jenkins
USER root
RUN curl -L \
"https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
USER jenkins
Or you can install docker-compose after the Jenkins container is already running via the same CURL command:
$ sudo curl -L https://github.com/docker/compose/releases/download/1.25.3/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
Upvotes: 1