Docker-compose module: #!shebang

You can make your docker-compose.yaml executable by adding a `shebang line as first line in the YAML file.

As you might know the shebang line is the first line in a shell script that determines which interpretor to run for the script. For Bash scripts it is usually #!/bin/env bash.

We can add a shebang line that tells the kernel that we want the Space module docker-compose to be the interpreter so it can directly run the yaml file.

For Linux add this line as the very first line in your docker-compose.yaml file:

#!/usr/bin/space -m docker-compose /_shebang/

For MacOS systems add this line instead:

#!/usr/bin/env space ! -m docker-compose /_shebang/ !

Then you need to make the yaml file executable:

$ chmod +x docker-compose.yaml

Alright, it should be runnable directly from command line:

$ ./docker-compose.yaml -- up
$ ./docker-compose.yaml -- ps
$ ./docker-compose.yaml -- down

Pretty neat, uh?

Oh, there is more. We can wrap it using the SSH module to have it being deployed remotely:

$ ./docker-compose.yaml -m ssh /wrap/ -eSSHHOST=address -- up

It is important to add -m ssh /wrap/ -eSSHHOST=address before the double dash --. Because everything left of -- are arguments to Space and everything to the right of -- are arguments to the module.

Remember, that if you want to see the magic behind the scenes, add the -d flag to Space to have it dump out the script for debugging, inspection and sharing.