Skip to content

Ruby Distroless builds minimal, secure Ruby runtime images on a distroless base, supporting Ruby 2.5–3.4 on both amd64 and arm64 platforms.

License

Notifications You must be signed in to change notification settings

junminhong/ruby-distroless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Distroless

License: MIT Build Status

繁體中文

Ruby Distroless is an open-source project designed to create a minimal and secure Ruby runtime environment using Google's distroless images.

This project enables you to easily build lightweight Ruby images supporting multiple platforms (e.g., amd64 and arm64) and multiple Ruby versions. It is optimized for production deployments, reducing security risks and minimizing image size.

Supported Ruby Versions

The supported Ruby versions range from Ruby 2.5 to Ruby 3.4, specifically including:

  • Ruby 2.5.9
  • Ruby 2.6.10
  • Ruby 2.7.8
  • Ruby 3.0.7
  • Ruby 3.1.6
  • Ruby 3.2.7
  • Ruby 3.3.7
  • Ruby 3.4.2

Features

  • Minimal and Secure: Built on distroless images, including only necessary runtime dependencies, avoiding unnecessary tools that may introduce security risks.
  • Multi-Platform Support: Utilizes Docker Buildx to build images for both amd64 and arm64 architectures.
  • Multiple Ruby Versions: Supports Ruby versions from 2.5 to 3.4, allowing users to select the appropriate version for their needs.
  • Automated CI/CD: Integrated with GitHub Actions for automatic builds and deployment to GitHub Container Registry (GHCR).

Installation

You can pull pre-built images from GitHub Container Registry (GHCR). For example, to pull the Ruby 3.3.7 amd64 image:

# amd64
docker pull ghcr.io/junminhong/ruby-distroless:3.3.7-amd64
# arm65
docker pull ghcr.io/junminhong/ruby-distroless:3.3.7-arm64

Usage

You can run Ruby directly using this image:

# amd64
docker run --rm ghcr.io/junminhong/ruby-distroless:3.3.7-amd64 ruby -v
# arm65
docker run --rm ghcr.io/junminhong/ruby-distroless:3.3.7-arm64 ruby -v

This will display the Ruby version. If you need to run other Ruby programs inside the container, refer to Docker's CMD instruction.

Building the Image

You can use the provided Dockerfile and build.sh script to build images manually.

Dockerfile

The Dockerfile utilizes multi-stage builds, extracting Ruby binaries and dependencies from the official Ruby slim image and copying them into a minimal distroless image. See Dockerfile for details.

build.sh

The build.sh script automates the process of building multiple Ruby versions.

  1. Grant execution permissions:
    chmod +x build.sh
  2. Set the platform environment variable for ARM builds:
    export PLATFORM=linux/arm64
  3. Enable pushing to the remote registry (optional):
    export PUSH_IMAGE=true
  4. Run the script:
    ./build.sh

GitHub Actions

This project uses GitHub Actions to automatically build multi-platform and multi-version Ruby images and push them to GitHub Container Registry (GHCR).

For more details, see .github/workflows/build.yml. The workflow triggers automatic builds whenever you push to the main branch or create a pull request.

Contributing

We welcome contributions in all forms! If you have ideas, bug reports, or feature enhancements, feel free to open an issue or submit a pull request.

Contribution Guidelines

  1. Fork this repository.
  2. Create a new branch and make modifications.
  3. Submit a pull request with detailed descriptions of your changes.
  4. We will review and respond to your PR as soon as possible.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

  • GitHub: junminhong
  • If you have any questions or suggestions, feel free to open an issue or submit a pull request.

About

Ruby Distroless builds minimal, secure Ruby runtime images on a distroless base, supporting Ruby 2.5–3.4 on both amd64 and arm64 platforms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages