Using Jenkins to control docker image build flow I'm trying to figure out the proper way to get build environments into a CI pipeline.

What I want to achieve is:


someone pushes to the docker source repo (not registry, a repo with the docker folder)
jenkins kicks off a build of that docker image
if successful docker then goes and runs a software build using the newly built docker image
if successful the docker image is tagged and pushed to the docker registry


All I have so far is a Jenkins file that has four stages


checks out out docker source repo
builds docker image from source
Checks out software source code (code that builds in the docker environment)
builds software source code in docker container
If successful tags and pushes new image to docker registery


My main concern is everything I'm doing is going to be in the 'script' blocks, except the git checkouts, and it feels super hacky to be building and kicking off docker builds with jenkins using bash...

are there any tools/already defined procedures to do things like this?  Is this the best way to do it?  I am looking for a best practice approach as this will be put into production and I want it to be as resilient and long lasting as possible.
I have found a solution so I'll leave it here for others.

using docker 

#!/usr/bin/env groovy

pipeline{
agent buildsvr

  stages{
    stage('Checkout and build Docker Source'){
      steps{
        checkout([
          $class: 'GitSCM',
          branches: [[name: '*/master']],
          doGenerateSubmoduleConfigurations: false,
          submoduleCfg: [],
          userRemoteConfigs: [[
            credentialsId: 'asdf787c-5fd4-4dfb-81ad-873jhf107223',
            url: 
'git@mydockersourcerepo.git']]])
        sh 'pushd docker &amp;&amp; docker build -t ${image}:latest . &amp;&amp; popd '
      }
    }
    stage('Checkout Target Source'){
      steps{
        script{
          checkout([
            $class: 'GitSCM',
            branches: [[name: 'mybranch']],
            doGenerateSubmoduleConfigurations: false,
            extensions: [[
              $class: 'SubmoduleOption',
              disableSubmodules: false,
              parentCredentials: false,
              recursiveSubmodules: true, reference: '',
              trackingSubmodules: true
              relativeTargetDir: 'source']],
            submoduleCfg: [],
            userRemoteConfigs: [[
              credentialsId: 'Bitbucket-Jenkins',
              url: 'ssh://git@sourcerepo.git']]])
        }
      }
    }
    stage('Build Source Target'){
      steps{
       script{
          sh 'docker-compose up'
        }
      }
    }
  }
  post{
    success{
      script{
        sh 'docker tag ${image} 10.90.239.223:5000:/${image} &amp;&amp; docker push 
10.90.239.223:5000:/${image}'
      }
    }
  }
}