Skip to content

Instantly share code, notes, and snippets.

@ppiotrow
Last active April 5, 2020 16:07
Show Gist options
  • Save ppiotrow/9438a5a2a7bf5c1b636a8353d80460ed to your computer and use it in GitHub Desktop.
Save ppiotrow/9438a5a2a7bf5c1b636a8353d80460ed to your computer and use it in GitHub Desktop.
image='dckr.myrepo.com/my-org/my-app'
stage0=$image':stage0'
latest=$image':latest'
# Pull to bring docker images to the docker cache.
docker pull $stage0 || true # ||true saves from failure when image has never been published
docker pull $latest || true
# This generates Dockerfile and artifacts
sbt docker:stage
docker build \
--target stage0 \ # build only itermediate image
--cache-from $stage0 \ # using cache downloaded from remote repository
--tag $stage0 "target/docker/stage/"
sbt docker:publishLocal # build final image defined in https://gist.github.com/ppiotrow/e6f3aae9368983579ed16a1f74fb0bbc
#Publish for the future cache hits.
docker push $stage0
docker push $latest
#Publish for deployment.
docker push $image$(git describe --tags) # I only deploy immutable tags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment