Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull images before running docker-compose up #179

Open
wants to merge 8 commits into
base: release/2.3.0
Choose a base branch
from
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ venv
# vscode custom files
local-storage.json
jcasc-schema.json

17 changes: 13 additions & 4 deletions src/eu/indigo/compose/DockerCompose.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DockerCompose extends JenkinsDefinitions implements Serializable {
String _f = '-f'
String _w = '--project-directory'
String _ipf = '--ignore-push-failures'
String _b = '--build'
String _b = '--no-cache'


/**
Expand Down Expand Up @@ -186,8 +186,17 @@ class DockerCompose extends JenkinsDefinitions implements Serializable {
* @see https://docs.docker.com/compose/reference/overview/
*/
def composeUp(Map args, String serviceIds='') {
String buildFlag = testString(args.forceBuild) ? _b : ''
String cmd = parseParam(_f, escapeWhitespace(args.composeFile)) + ' ' + parseParam(_w, escapeWhitespace(args.workdir)) + " up $buildFlag -d $serviceIds"
cmdCommon = parseParam(_f, escapeWhitespace(args.composeFile)) + ' ' + parseParam(_w, escapeWhitespace(args.workdir))
if testString(args.forceBuild) {
String buildFlag = _b
String cmdRm = "$cmdCommon rm -f -v -s $serviceIds"
String cmdPull = "$cmdCommon pull $serviceIds"
String cmdBuild = "$cmdCommon build $buildFlag $serviceIds"
steps.sh "docker-compose $cmdRm"
steps.sh "docker-compose $cmdPull"
steps.sh "DOCKER_BUILDKIT=1 docker-compose $cmdBuild"
}
String cmd = "$cmdCommon up -d $serviceIds"

steps.sh "docker-compose $cmd"
}
Expand Down Expand Up @@ -332,7 +341,7 @@ class DockerCompose extends JenkinsDefinitions implements Serializable {
withCredentialsClosure(credentials) {
// Deploy the environment services using docker-compose
composeUp(composeFile: projectConfig.config.deploy_template, workdir: workspace, forceBuild: steps.env.JPL_DOCKERFORCEBUILD)

if (_DEBUG_) { steps.sh 'echo "after loading credentials:\n$(env)"' }

projectConfig.stagesList.each { stageMap ->
Expand Down