Skip to content

Instantly share code, notes, and snippets.

@rbuckland
Created December 16, 2015 22:43
Show Gist options
  • Select an option

  • Save rbuckland/41334fb2bec768cec35c to your computer and use it in GitHub Desktop.

Select an option

Save rbuckland/41334fb2bec768cec35c to your computer and use it in GitHub Desktop.
Using Ammonite as a "Shell Script" Replacement (a test)

Overview

I have been working on a project with a number of docker containers that are either run on a local machine, or on a remote machine.

The process is fairly simple, I either need to "build" a docker image, "run" a container, from an image, and/ or push an image to a local docker repository.

The process is like this

dockers/
    name-of-image/DockerFile
                 /... other files
    docker2/Dockerfile
    docker3/Dockerfile
    ...
    docker-n/Dockerfile

A YAML file describes which dockers "for this stage", I want to "build", run and push Sometimes a run is a remote image (eg: registry:2 - the docker registry), and sometimes I just want to build and run.

This was encapsulated in a shell script, but will all shell scripts that get 'big', they quickly turn to problematic.

Here I am exploring how to do the above, using Ammonite, a Scala REPL / Scala Shell runner.

#!/bin/bash
# pass in as arguments, the path to the YAML file (can be relative)
DOCKERS_YAML=$1
# .. and the "full path" to the folder of docker images (MUST BE FULL PATH .. use `pwd`/some/path)
DOCKERSPATH=$2
amm -p 'load.ivy("net.jcazevedo" %% "moultingyaml" % "0.1")' bootstrap.scala ${DOCKERS_YAML} ${DOCKERSPATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment