Created
October 12, 2015 22:13
-
-
Save chasebolt/7ef0c78aa5f870e14173 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe 'docker-apps' | |
Chef::Resource::DockerContainer.class_eval do | |
property :dependencies_updated, [true, false] | |
def depends_on(resource) | |
subscribes :dependencies_updated, resource, :immediately | |
subscribes :run, resource | |
end | |
action :dependencies_updated do | |
new_resource.dependencies_updated true | |
end | |
module NewCreateAction | |
def action_create | |
super | |
new_resource.reset_property(:dependencies_updated) | |
end | |
end | |
# This puts NewCreateAction::action_create as the first thing called, and super() == DockerContainer::action_create | |
prepend NewCreateAction | |
end | |
# And then change subscribes to depends_on in your recipe: | |
directory '/tmp' | |
file '/tmp/some_config.ini' do | |
content 'blah' | |
action :create | |
end | |
file '/tmp/another_config.ini' do | |
content 'blah' | |
action :create | |
end | |
docker_image 'alpine' do | |
tag 'latest' | |
action :pull_if_missing | |
end | |
docker_container 'alpine' do | |
command 'sleep 3000' | |
depends_on 'docker_image[some_image]' | |
depends_on 'file[/tmp/some_config.ini]' | |
depends_on 'file[/tmp/another_config.ini]' | |
action :run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment