Skip to content

Instantly share code, notes, and snippets.

@jgoulah
Last active July 18, 2016 03:10
Show Gist options
  • Select an option

  • Save jgoulah/83b4d484cf314259200aaab42f516a06 to your computer and use it in GitHub Desktop.

Select an option

Save jgoulah/83b4d484cf314259200aaab42f516a06 to your computer and use it in GitHub Desktop.
##########################################################################
# first require the chef provisioning driver found at:
# https://github.com/chef/chef-provisioning-docker
##########################################################################
require 'chef/provisioning/docker_driver'
with_driver 'docker'
##########################################################################
# this defines the container instance including the role, any attributes,
# the volumes to mount, ports to open, and docker image to use
##########################################################################
machine 'devserver' do
##########################################################################
# the role to use, a collection of recipes defined elsewhere
##########################################################################
role 'Dev'
##########################################################################
# you can define custom attributes create the container with, in this case
# the dev container user which mirrors the system username and group
# the recipe is defined in the role: recipe 'users::dev_user'
##########################################################################
attribute 'users', {
'dev_user' => ENV['USER'],
'shell' => ENV['SHELL'],
'uid' => %x{id -u #{ENV['USER']} | tr -d '\n'},
'gid' => %x{id -G #{ENV['USER']} | awk '{print $1}' | tr -d '\n'},
}
##########################################################################
# these machine options define which docker image to use and
# the volumes to mount, ports to open, and default command to run
##########################################################################
machine_options(
:docker_options => {
:base_image => {
:name => "yourorg/dev-base-image",
:repository => 'yourorg',
:tag => 'latest'
},
:volumes => ["/Users/#{ENV['USER']}:/home/#{ENV['USER']}"],
:workdir => "/home/#{ENV['USER']}",
:command => "sudo -u <<your daemon here>>",
:ports => ["3000:3000", "7778:7778"]
}
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment