Class: BoringBuilder::RubyBuild

Inherits:
Object
  • Object
show all
Defined in:
lib/boringbuilder/ruby_build.rb

Direct Known Subclasses

RailsBuild

Constant Summary collapse

DEFAULT_BUILD_IMAGE =
Mise::DEFAULT_IMAGE
DEFAULT_RUNTIME_IMAGE =
BoringCache::CLI_IMAGE
BUILD_PACKAGES =
%w[
  build-essential
  curl
  git
  libpq-dev
  libyaml-dev
  pkg-config
].freeze
RUNTIME_PACKAGES =
%w[
  curl
  libpq5
].freeze
BUNDLE_ENVIRONMENT =
{
  "BUNDLE_CLEAN" => "true",
  "BUNDLE_DEPLOYMENT" => "1",
  "BUNDLE_IGNORE_CONFIG" => "true",
  "BUNDLE_JOBS" => "1",
  "BUNDLE_PATH" => "/usr/local/bundle",
  "BUNDLE_WITHOUT" => "development:test"
}.freeze
BUNDLE_INSTALL_COMMAND =
["sh", "-c", "bundle install && bundle clean --force"].freeze
BUNDLE_FILES =
%w[Gemfile Gemfile.lock .ruby-version].freeze
BUNDLE_CONFIG =
<<~YAML
  ---
  BUNDLE_PATH: "vendor/bundle"
  BUNDLE_WITHOUT: "development:test"
  BUNDLE_JOBS: "1"
  BUNDLE_CLEAN: "true"
YAML

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, client, progress: BuildProgress.silent) ⇒ RubyBuild

Returns a new instance of RubyBuild.



39
40
41
42
43
# File 'lib/boringbuilder/ruby_build.rb', line 39

def initialize(project, client, progress: BuildProgress.silent)
  @project = project
  @client = client
  @progress = progress
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



37
38
39
# File 'lib/boringbuilder/ruby_build.rb', line 37

def client
  @client
end

#progressObject (readonly)

Returns the value of attribute progress.



37
38
39
# File 'lib/boringbuilder/ruby_build.rb', line 37

def progress
  @progress
end

#projectObject (readonly)

Returns the value of attribute project.



37
38
39
# File 'lib/boringbuilder/ruby_build.rb', line 37

def project
  @project
end

Instance Method Details

#containerObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/boringbuilder/ruby_build.rb', line 45

def container
  builder = with_environment(build_image_container, build_environment)
  builder = install_packages(builder, (BUILD_PACKAGES + configuration.build_packages).uniq)
  builder = create_application_user(builder)
  builder = install_toolchain(builder)
  builder = install_gems(builder)
  builder = builder.with_directory(application_path, project.source(client), owner: user_owner)
  builder = builder.with_workdir(application_path).with_exec(%w[bundle check])
  builder = precompile(builder)
  builder = write_bundle_config(builder)
  builder = progress.step("Build #{project.framework.to_s.capitalize} application") { builder.sync }

  runtime_container(builder)
end