shipyard/shipyard — pull request #250 by ehazlett (2014-09-18 03:25:12+00:00)
Title: extensions

This adds initial support for "extension images". This gives the controller the ability to add/remove/view extensions as well as control from the CLI. Here is how it works:

1. user runs `add-extension --url http://host/path/to/shipyard.extension` to add an extension image to Shipyard
2. cli checks config for image arguments or environment variables that need values and prompts as needed
3. Shipyard "registers" extension and runs container(s)

Here is an example config (https://raw.githubusercontent.com/ehazlett/interlock/master/.shipyard.extension):

```json
{
"config": {
"deploy_per_engine": false,
"ports": [
{
"container_port": 8080,
"port": 80,
"proto": "tcp"
}
],
"memory": 32,
"cpus": 0.1,
"prompt_args": [
"-shipyard-url",
"-shipyard-service-key"
]
},
"url": "https://github.com/ehazlett/interlock",
"description": "Application Router and Load Balancer",
"author": "ehazlett",
"version": "0.1",
"image": "ehazlett/interlock",
"name": "interlock"
}
```

The following fields are in place:

* `name`: creator designated name of extension
* `image`: Docker image that is used (must be on the Docker Hub)
* `version`: extension version
* `author`: extension author
* `description`: short description of extension
* `url`: url to extension source
* `config`: container run config
* `cpus`: number of cpu shares
* `memory`: amount of memory (in MB)
* `ports`: ports published when container is started
* `deploy_per_engine`: this will run a container for each engine in the cluster
* `prompt_args`: array of container arguments that user is prompted to enter upon adding
* `prompt_env`: array of container environment variables that user is prompted to enter upon adding

The `prompt_args` and `prompt_env` allow the extension to prompt the user for configuration values before launching.

Here is an example CLI add:

```
$> shipyard-cli add-extension --url https://gist.githubusercontent.com/ehazlett/2b7d190498bd2c0f532e/raw/153208e860b1af414b229d85485508fb47e740e1/gistfile1.json
configuring test (https://github.com/ehazlett/go-demo for more info)
enter value for container environment variable "VERSION": test
enter value for container environment variable "URL": shipyard-project.com
added extension name=test version=0.1
```

You can test this out now with the `shipyard/shipyard:test` controller image and `shipyard/shipyard-cli:test` cli image.

Feedback welcome :)