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_PATH" => "/usr/local/bundle",
  "BUNDLE_WITHOUT" => "development:test"
}.freeze
BUNDLE_INSTALL_COMMAND =
[
  "sh", "-c",
  'export BUNDLE_JOBS="${BUNDLE_JOBS:-$(nproc)}"; bundle install && bundle clean --force'
].freeze
APT_INSTALL_COMMAND =
[
  "sh", "-c",
  "apt-get update && apt-get install -y --no-install-recommends \"$@\" && rm -rf /var/lib/apt/lists/*",
  "apt-get"
].freeze
BUNDLE_FILES =
%w[Gemfile Gemfile.lock .ruby-version].freeze
BUNDLE_CONFIG =
<<~YAML
  ---
  BUNDLE_PATH: "vendor/bundle"
  BUNDLE_WITHOUT: "development:test"
  BUNDLE_CLEAN: "true"
YAML

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of RubyBuild.



45
46
47
48
49
# File 'lib/boringbuilder/ruby_build.rb', line 45

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

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



43
44
45
# File 'lib/boringbuilder/ruby_build.rb', line 43

def client
  @client
end

#progressObject (readonly)

Returns the value of attribute progress.



43
44
45
# File 'lib/boringbuilder/ruby_build.rb', line 43

def progress
  @progress
end

#projectObject (readonly)

Returns the value of attribute project.



43
44
45
# File 'lib/boringbuilder/ruby_build.rb', line 43

def project
  @project
end

Instance Method Details

#containerObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/boringbuilder/ruby_build.rb', line 51

def container
  builder = with_environment(build_image_container, build_environment)
  builder = install_packages(builder, (BUILD_PACKAGES + configuration.build_packages).uniq, stage: :build)
  builder = create_application_user(builder, stage: :build)
  builder = install_toolchain(builder)
  builder = install_gems(builder)
  builder = pipeline.step("[build] COPY application source", builder) do |container|
    container.with_directory(application_path, project.source(client), owner: user_owner)
  end
  builder = pipeline.exec(
    builder,
    %w[bundle check],
    name: "[build] RUN bundle check",
    workdir: application_path
  )
  builder = precompile(builder)
  builder = pipeline.step("[build] Write Bundler configuration", builder) { write_bundle_config(_1) }

  runtime_container(builder)
end