Using Docker for Development

Net::SSH provides a comprehensive Docker setup to create a consistent and reproducible environment for running tests across multiple Ruby versions. This is the recommended way to run the full test suite.

Prerequisites

  • Docker
  • Docker Compose

Running All Tests

The docker-compose.yml file defines services for each supported Ruby version. To build the images and run the test suite against all of them, use the up command:

docker-compose up --build

This command will:

  1. Build a Docker image for each Ruby version specified (3.1, 3.0, 2.7, 2.6).
  2. Install all dependencies inside each container.
  3. Run the full test suite, including integration tests, inside each container.

Running Tests for a Single Ruby Version

If you only want to test against a specific Ruby version, you can use docker compose run:

# Build the images first if you haven't already
docker-compose build

# Run tests for Ruby 3.1
docker compose run ruby-3.1

# Run tests for Ruby 2.6
docker compose run ruby-2.6

Specialized Test Environments

Net::SSH also includes specialized Dockerfiles for testing against specific system library configurations.

Testing with OpenSSL 3

The Dockerfile.openssl3 is based on Ubuntu 22.04, which uses OpenSSL 3. This is crucial for ensuring compatibility with modern cryptographic libraries. You can build and run these tests with:

docker build -t netssh_openssl3 -f Dockerfile.openssl3 .
docker run --rm netssh_openssl3

Testing with zlib-ng

The Dockerfile.zlib_ng is based on Fedora and uses zlib-ng, a modern fork of the zlib compression library. This ensures that SSH compression works correctly with this library.

docker build -t netssh_zlib_ng -f Dockerfile.zlib_ng .
docker run --rm netssh_zlib_ng

These specialized environments are also run as part of the project's Continuous Integration (CI) pipeline, as defined in .github/workflows/ci-with-docker.yml.