Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add possibilities to add capabilities and devices to docker container #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libraries/env_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def links
stringify app_config["links"], "--link"
end

def capabilities
stringify app_config["capabilities"], "--cap-add"
end

def devices
stringify app_config["devices"], "--device"
end

def stringify(vals, parameter)
(vals || []).inject("") do |memo, value|
memo + "#{parameter} #{value.to_s % interpolations} "
Expand Down
4 changes: 2 additions & 2 deletions recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
execute "migrate #{app_name}#{i} container" do
special_node = NodesHelper.special_node node
Chef::Log.info("Migrating #{app_name}#{i}... (only on #{special_node})")
command "docker run --rm #{e.env_string(environment)} #{e.links} #{e.volumes} #{e.volumes_from} #{image}:#{tag} #{app_config["migration"]}"
command "docker run --rm #{e.env_string(environment)} #{e.links} #{e.volumes} #{e.volumes_from} #{e.capabilities} #{e.devices} #{image}:#{tag} #{app_config["migration"]}"
only_if { e.migrate? && i == 0 && e.auto? && special_node == node[:opsworks][:instance][:hostname]}
end

Expand All @@ -58,7 +58,7 @@
environment["RELEASE_TAG"] = history.stdout.strip

Chef::Log.info("Launching #{image}...")
command "docker run -d -h #{e.hostname i} --name #{app_name}#{i} #{e.ports} #{e.env_string(environment)} #{e.links} #{e.volumes} #{e.volumes_from} #{e.entrypoint} #{image}:#{tag} #{e.cmd i}"
command "docker run -d -h #{e.hostname i} --name #{app_name}#{i} #{e.ports} #{e.env_string(environment)} #{e.links} #{e.volumes} #{e.volumes_from} #{e.capabilities} #{e.devices} #{e.entrypoint} #{image}:#{tag} #{e.cmd i}"
not_if "docker ps -f status=running | grep ' #{app_name}#{i} '"
end
end
Expand Down