Skip to content

uzyexe/chef-docker-compose

Repository files navigation

Requirements

The cookbook should run on any Linux flavor and it depends on the following cookbooks:

Attributes

Key Type Description Default
['docker-compose']['config_directory'] String Specifies docker-compose yaml configuration storage directory /etc/compose.d

Usage

docker-compose resource

Actions

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.

Attributes

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}

Invocation

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'
  })
end

One-off commands with docker-compose

Docker-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].

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Authors

Authors: Shuji Yamada (uzy.exe@gmail.com)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages