Class: Spectat::Jekyll::RakeTask::DockerHelper
- Inherits:
-
Object
- Object
- Spectat::Jekyll::RakeTask::DockerHelper
- Defined in:
- lib/spectat/jekyll/rake_task/helper.rb
Overview
Helper class for standardising Docker configuration
Constant Summary collapse
- VALID_IMAGE_TYPES =
%i[builder built deploy].freeze
Instance Attribute Summary collapse
-
#full_repo_path ⇒ Object
readonly
Returns the value of attribute full_repo_path.
-
#image_tag ⇒ Object
readonly
Returns the value of attribute image_tag.
-
#image_type ⇒ Object
readonly
Returns the value of attribute image_type.
Instance Method Summary collapse
- #docker_build_command ⇒ Object
- #image_path ⇒ Object
-
#initialize(full_repo_path, image_type, image_tag) ⇒ DockerHelper
constructor
A new instance of DockerHelper.
- #path_to_dockerfile(executing_script_path) ⇒ Object
Constructor Details
#initialize(full_repo_path, image_type, image_tag) ⇒ DockerHelper
Returns a new instance of DockerHelper.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 15 def initialize(full_repo_path, image_type, image_tag) raise ArgumentError, 'image_type must be ' + VALID_IMAGE_TYPES.to_s unless VALID_IMAGE_TYPES.include?(image_type) @full_repo_path = full_repo_path @image_type = image_type @image_tag = image_tag @image_name = case @image_type when :built '' else "/#{@image_type}" end end |
Instance Attribute Details
#full_repo_path ⇒ Object (readonly)
Returns the value of attribute full_repo_path.
9 10 11 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 9 def full_repo_path @full_repo_path end |
#image_tag ⇒ Object (readonly)
Returns the value of attribute image_tag.
11 12 13 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 11 def image_tag @image_tag end |
#image_type ⇒ Object (readonly)
Returns the value of attribute image_type.
10 11 12 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 10 def image_type @image_type end |
Instance Method Details
#docker_build_command ⇒ Object
33 34 35 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 33 def docker_build_command "docker build --pull --cache-from #{image_path} --tag #{image_path} --file #{path_to_dockerfile(__FILE__)} ." end |
#image_path ⇒ Object
29 30 31 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 29 def image_path "registry.gitlab.com/#{@full_repo_path}#{@image_name}:#{@image_tag}" end |
#path_to_dockerfile(executing_script_path) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/spectat/jekyll/rake_task/helper.rb', line 37 def path_to_dockerfile(executing_script_path) dockerfile = "Dockerfile.#{@image_type}.erb" full_path = File.join(File.dirname(executing_script_path), dockerfile) raise IOError, "#{full_path} doesn't exist" unless File.file?(full_path) full_path end |