The cookbook should run on any Linux flavor and it depends on the following cookbooks:
- docker cookbook (chef-cookbooks/docker)
- python cookbook
| Key | Type | Description | Default |
|---|---|---|---|
| ['docker-compose']['config_directory'] | String | Specifies docker-compose yaml configuration storage directory | /etc/compose.d |
| Action | Description |
|---|---|
| :up | Builds/pulls, (re)creates and starts containers |
| :start | Starts containers |
| :stop | Stops containers |
| :kill | Kills containers |
| :destroy | Kills and removes containers along with the configuration |
| :run | Invokes one-off docker-compose run command. |
| Attribute | Description |
|---|---|
| project | Project name of docker-compose environment. Default value: default. |
| recreate | When set to true containers are recreated on every action :up. Default value: false. |
| source | The source of yaml configuration file. It can be either a cookbook file or a template (if the source string ends with .erb). In case the source is an URI or an array of URIs remote_file resource is used. |
| cookbook | The originating cookbook of a cookbook file or a template. |
| variables | A hash of variables which is passed to the template for its generation. |
| service | Service name used during docker-compose command. By default commands are applied to all docker-compose services defined in the environment yaml. |
| run_opts | Hash with configuration for one off command. Default value: {remove: true, no_deps: true} |
docker_compose 'training-webapp' do
action :up
source 'training.yml'
end
# one-off command example
docker_compose 'training one-off' do
action :run
source 'training.yml'
service 'child'
run_opts({
command: %Q(-c "echo hello from one-off"),
entrypoint: '/bin/sh'
})
endDocker-compose resource provider operates differently from default docker-compose run, the key moment is that options --rm and --no-deps are enabled by default. Another nice thing helps you to dynamically redefine the entrypoint for a service in case this is needed just specify run_opts[:entrypoint].
- Fork the repository on Github
- Create a named feature branch (like
add_component_x) - Write your change
- Write tests for your change (if applicable)
- Run the tests, ensuring they all pass
- Submit a Pull Request using Github
Authors: Shuji Yamada ([email protected])