library('jenkins_build')

node {
    main {
        def dockerImageName = "registry.elbert.us/parsley"
        def dockerImage

        stage("Checkout") {
            checkout scm
        }

        stage("Build") {
            dockerImage = docker.build("${dockerImageName}:latest")
        }

        stage("Publish") {
            dockerImage.push()
            dockerImage.push(env.JOB_BASE_NAME)
        }

        if (env.BRANCH_NAME == "production") {
            stage("Deploy") {
                remote_deploy("azathoth.thenever", "parsley", "./docker-compose-azathoth.yml")
            }
        }
    }
}
