diff --git a/README.md b/README.md index 5044d15..b211119 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ up a ready-to-roll mongodb or openldap server, it does what it is supposed to. - [x] Add filtering to `find` command, to seach for tags or name - [ ] App port binding, i.e. phpmyadmin on 9000, phpcacheadmin on 9001 - [ ] Make use of a `~/.serverenvs` to override envs for instances -- [ ] Consider UDP? +- [x] Consider UDP? ## Examples @@ -53,6 +53,39 @@ Stopped mongo $ ``` +## Service definition + +Services are defined as JSON and should be put in the `registry` directory, which +should be located in the same directory as the executable (when using phar) or in +the project root when running from source. + +```json +{ + "$type": "service", + "name": "myservice", + "description": "My neat service", + "tags": [ "app", "neat" ], + "author": "Myself ", + "image": "myself/myservice", + "ports": [ + { "port": 1337, "info": "Neat port" }, + { "port": 1337, "info": "Neat port (UDP)", "proto": "udp" } + ], + "persistence": [ + { "path": "/data", "hint": "Fancy data" } + ], + "environment": { + "NEAT_ENV_VAR": "useful value", + }, + "scripts": { + "setup": { + "info": "Launch the neat configuration tool", + "execute": "/app/setup.sh" + } + } +} +``` + ## FAQ diff --git a/src/Container/ContainerManager.php b/src/Container/ContainerManager.php index d1d1ec7..378ac7d 100644 --- a/src/Container/ContainerManager.php +++ b/src/Container/ContainerManager.php @@ -119,9 +119,10 @@ class ContainerManager foreach ($ports as $port) { $portNumber = intval($port['port']) + $portOffset; $target = array_key_exists('target',$port)?intval($port['target']):intval($port['port']); + $proto = $port['proto']??"tcp"; $args[] = '-p'; - $args[] = $portNumber.":".$target; - $mappedPorts[$port['info']] = $portNumber; + $args[] = $portNumber.":".$target."/".$proto; + $mappedPorts[$port['info']] = $portNumber."/".$proto; } // Get the paths to persist