Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
(MAINT) Add ability to include local modules
Browse files Browse the repository at this point in the history
As per conversation on #16
  • Loading branch information
garethr committed Feb 12, 2017
1 parent ee0559c commit d823af4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -313,6 +313,7 @@ USAGE: puppet docker <action> [--from STRING]
[--os-version STRING]
[--puppet-agent-version STRING]
[--r10k-version STRING]
[--module-path PATH]
[--expose STRING]
[--cmd STRING]
[--entrypoint STRING]
Expand Down Expand Up @@ -353,6 +354,8 @@ OPTIONS:
--maintainer STRING - Name and email address for the maintainer of
the resulting image
--master STRING - A Puppet Master to use for building images
--module-path PATH - A path to a directory containing a set of
modules to be copied into the image
--os STRING - The operating system used by the image if not
autodetected
--os-version STRING - The version of the operating system used by
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet_x/puppetlabs/imagebuilder_face.rb
Expand Up @@ -30,6 +30,10 @@ class ImageBuilder::Face < Puppet::Face
default_to { '2.2.2' }
end

option '--module-path PATH' do
summary 'A path to a directory containing a set of modules to be copied into the image'
end

option '--expose STRING' do
summary 'A list of ports to be exposed by the resulting image'
end
Expand Down
19 changes: 18 additions & 1 deletion spec/support/examples/imagebuilder.rb
@@ -1,4 +1,4 @@
shared_examples 'an image builder' do
shared_examples 'an image builder' do #rubocop:disable Metrics/BlockLength
context 'without any arguments' do
let(:args) { {} }
it 'should raise an error about missing operating system details' do
Expand Down Expand Up @@ -357,6 +357,23 @@
end
end

context 'with a module path provided' do
let(:module_path) { '/example/directory' }
let(:args) do
{
from: 'alpine:3.4',
image_name: image_name,
module_path: module_path,
}
end
it 'should not raise an error' do
expect { context }.not_to raise_error
end
it 'should produce a context with a module path' do
expect(context).to include(module_path: module_path)
end
end

context 'with an alternative operating system' do
let(:args) do
{
Expand Down
4 changes: 4 additions & 0 deletions templates/Dockerfile.erb
Expand Up @@ -76,6 +76,10 @@ COPY <%= puppetfile %> /Puppetfile
RUN <%= r10k_path %> puppetfile install --moduledir /etc/puppetlabs/code/modules
<% end %>
<% if module_path && !master %>
COPY <%= module_path %> /etc/puppetlabs/code/modules/
<% end %>
<% if manifest && !master %>
COPY <%= File.dirname(manifest) %> /<%= File.dirname(manifest) %>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions templates/build-aci.sh.erb
Expand Up @@ -80,6 +80,10 @@ acbuild run -- rm -rf /var/cache/apk/*
acbuild --debug copy <%= puppetfile %> /Puppetfile
<% end %>

<% if module_path && !master %>
acbuild --debug copy <%= module_path %> /etc/puppetlabs/code/modules/
<% end %>

<% if manifest && !master %>
acbuild --debug copy <%= File.dirname(manifest) %> /<%= File.dirname(manifest) %>
<% end %>
Expand Down

0 comments on commit d823af4

Please sign in to comment.