From 6217672d82ff7059a7338e96755c9d6ebe9daff1 Mon Sep 17 00:00:00 2001 From: Tim Sharpe Date: Mon, 4 Nov 2019 19:29:48 +1100 Subject: [PATCH] (#794) Dockerfile for puppet-lint Before we begin, it should be noted that I don't regularly use Docker so there may be some bad practices here. If so, please let me know. This Dockerfile is pretty minimal and creates a working image of ~21MB which I think is pretty good (5MB of that is alpine and 15MB is the Ruby runtime). The files to be linted should be mounted to the `/puppet` volume, e.g. linting the manifests in my current directory: ``` $ docker run --rm -v $PWD:/puppet rodjek/puppet-lint *.pp 866.pp - ERROR: gh::issue866 not in autoload module layout on line 2 869.pp - ERROR: profile::users not in autoload module layout on line 2 869.pp - ERROR: profile::users::geco not in autoload module layout on line 22 ``` If this seems OK to the interested parties, I'll merge this and then set up automatic build & push on tag to Docker Hub. --- .dockerignore | 19 +++++++++++++++++++ Dockerfile | 11 +++++++++++ puppet-lint.gemspec | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..5c380cab --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +/*.pp +/*.gem +/.bundle +/.git +/.gitignore +/.rspec +/.rubocop_todo.yml +/.rubocop.yml +/.ruby-version +/.travis.yml +/appveyor.yml +/CHANGELOG.md +/coverage +/Gemfile +/Gemfile.lock +/Rakefile +/README.md +/spec +/tmp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..25900671 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.10 + +RUN apk add --no-cache ruby=2.5.7-r0 ruby-json=2.5.7-r0 && \ + mkdir /puppet-lint /puppet + +VOLUME /puppet +WORKDIR /puppet +ENTRYPOINT ["/puppet-lint/bin/puppet-lint"] +CMD ["--help"] + +COPY . /puppet-lint/ diff --git a/puppet-lint.gemspec b/puppet-lint.gemspec index 70fcd6b6..4ccfbcc1 100644 --- a/puppet-lint.gemspec +++ b/puppet-lint.gemspec @@ -9,9 +9,9 @@ Gem::Specification.new do |s| s.description = 'Checks your Puppet manifests against the Puppetlabs style guide and alerts you to any discrepancies.' - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } + s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'bin/**/*', 'spec/**/*'] + s.test_files = s.files.grep(%r{\Aspec/}) + s.executables = s.files.grep(%r{\Abin/}) { |f| File.basename(f) } s.require_paths = ['lib'] s.authors = ['Tim Sharpe']