Class: Kuby::Docker::Packages::Yarn

Inherits:
Package
  • Object
show all
Defined in:
lib/kuby/docker/packages/yarn.rb

Instance Attribute Summary

Attributes inherited from Package

#name, #version

Instance Method Summary collapse

Methods inherited from Package

#managed?, #with_version

Constructor Details

#initialize(name, version = nil) ⇒ Yarn

T::Sig::WithoutRuntime.sig { params(name: Symbol, version: T.nilable(String)).void }



10
11
12
13
14
# File 'lib/kuby/docker/packages/yarn.rb', line 10

def initialize(name, version = nil)
  super

  # @url = T.let(@url, T.nilable(String))
end

Instance Method Details

#install_on_alpine(dockerfile) ⇒ Object

T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/kuby/docker/packages/yarn.rb', line 33

def install_on_alpine(dockerfile)
  dockerfile.run(<<~CMD.strip)
    wget #{url} && \\
      yarnv=$(basename $(ls yarn-*.tar.gz | cut -d'-' -f 2) .tar.gz) && \\
      tar zxvf yarn-$yarnv.tar.gz -C /opt && \\
      mv /opt/yarn-$yarnv /opt/yarn && \\
      apk add --no-cache gnupg && \\
      wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import && \\
      wget https://github.com/yarnpkg/yarn/releases/download/$yarnv/yarn-$yarnv.tar.gz.asc && \\
      gpg --verify yarn-$yarnv.tar.gz.asc
  CMD

  dockerfile.env("PATH=$PATH:/opt/yarn/bin")
end

#install_on_debian(dockerfile) ⇒ Object

T::Sig::WithoutRuntime.sig { params(dockerfile: Dockerfile).void }



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kuby/docker/packages/yarn.rb', line 17

def install_on_debian(dockerfile)
  dockerfile.run(<<~CMD.strip)
    wget #{url} && \\
      yarnv=$(basename $(ls yarn-*.tar.gz | cut -d'-' -f 2) .tar.gz) && \\
      tar zxvf yarn-$yarnv.tar.gz -C /opt && \\
      mv /opt/yarn-$yarnv /opt/yarn && \\
      apt-get install -qq -y --no-install-recommends gnupg && \\
      wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import && \\
      wget https://github.com/yarnpkg/yarn/releases/download/$yarnv/yarn-$yarnv.tar.gz.asc && \\
      gpg --verify yarn-$yarnv.tar.gz.asc
  CMD

  dockerfile.env("PATH=$PATH:/opt/yarn/bin")
end