HUB
Sign inSign up

lulzon/ruby:latest

Multi-platform
Languages & frameworks
Manifest digest

sha256:0d67ce15c6a7ee01aa4f7c86f0aed4c85a222cf88db5bc5cbcced78421a1ae30

Last pushed

9 days by lulzon

Type

Sandbox Kit

Manifest digest

sha256:0d67ce15c6a7ee01aa4f7c86f0aed4c85a222cf88db5bc5cbcced78421a1ae30

yaml
schemaVersion: "3"
displayName: Ruby
author: Nick Lozon <[email protected]>
description: Install ruby as a mixin
sourceUrl: https://github.com/nicklozon/sbx-ruby-mixin
kind: mixin
capabilities:
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: |
                set -eu
                RUBY_VERSION='${{ kit.args.version }}'

                case "$(uname -m)" in
                  x86_64) asset_arch=x86_64 ;;
                  aarch64|arm64) asset_arch=arm64 ;;
                  *) echo "jdx/ruby publishes no $(uname -m) binaries" >&2; exit 1 ;;
                esac

                # jdx/ruby tags each release with the bare version (e.g. 4.0.9) and builds
                # portable tarballs, so they are not tied to a particular distro's glibc.
                asset="ruby-${RUBY_VERSION}.${asset_arch}_linux.tar.gz"
                url="https://github.com/jdx/ruby/releases/download/${RUBY_VERSION}/${asset}"
                curl -fsSL -o /tmp/runtime.tar.gz "${url}"
                tar xzf /tmp/runtime.tar.gz --strip-components=1 -C /usr/local

                # The Ruby tree above is root-owned, so install gems into a separate directory
                # the sandbox user can write to, as the official ruby Docker image does.
                # /etc/sandbox-persistent.sh is what the sandbox's shells and agent source.
                gem_home=/usr/local/bundle
                mkdir -p "${gem_home}"
                chmod 1777 "${gem_home}"
                {
                  echo "export GEM_HOME=${gem_home}"
                  echo 'case ":$PATH:" in *":$GEM_HOME/bin:"*) ;; *) export PATH="$GEM_HOME/bin:$PATH" ;; esac'
                } >> /etc/sandbox-persistent.sh
              user: "0"
    - type: com.docker.sandbox/network-policy@1
      config:
        runtime:
            allow:
                - rubygems.org:443
                - index.rubygems.org:443
args:
    version:
        default: 3.4.0
        description: Release to install, as published by jdx/ruby.
        pattern: ^[0-9]+\.[0-9]+\.[0-9]+$