I'm currently trying to deploy a Golang API using Jenkins on Docker. I've already configured everything so that Jenkins would have access to the correct repository it supposed to access. A Jenkinsfile is provided so that it would use the command docker-compose
to set up the build. So this means that the API itself will be containerized.
The Jenkinsfile looks something like this.
pipeline {
agent any
stages {
stage('deploy') {
steps {
dir("swagger/"){
sh """
sed -i 's/\\/api\\/v1/\\/dev\\/api\\/v1/g' swagger.json && sed -i 's/\\/uploads/\\/dev\\/uploads/g' swagger.json
"""
}
dir("deployments/docker/") {
sh "export JENKINS_NODE_COOKIE=dontKillMe && ./start.sh"
}
}
}
}
post {
success {
emailext body: 'Good news! The build bare fruits!', recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], subject: 'Build Successful'
}
failure {
emailext body: 'Try again probs?', recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], subject: 'Build Failed'
}
}
}
The deployment part starts when Jenkins tries to run ./start.sh
. The file start.sh
has only one line that to run the command docker-compose --compatibility up -d --build
.
However, as I soon found out, when Jenkins was trying to build the API, it performs the build inside of the Docker container instead of on the host machine. I want to make sure the API is built on the host machine and not on the container.
In other words, this means that I will be having a docker container within a docker container. I'm not really sure, but that's not what I want specifically. What I want is to make sure that both the Jenkins and API docker containers are running in the same host machine.
I've read a couple of suggestions from here and here, but it seems I didn't found the answer I needed.
My question would be How to make Jenkins on Docker perform the build on the host machine instead of the container? Is there something that I might be missing? Thanks in advance