{"id":25949810,"url":"https://github.com/yegor256/donce","last_synced_at":"2025-10-04T14:41:35.480Z","repository":{"id":276082602,"uuid":"928135028","full_name":"yegor256/donce","owner":"yegor256","description":"Docker Once: builds a temporary Docker image, runs a temporary Docker container, lets your tests interact with it, terminates and cleans up","archived":false,"fork":false,"pushed_at":"2025-09-25T21:14:28.000Z","size":152,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-25T23:32:34.025Z","etag":null,"topics":["automated-testing","docker","ruby","testing","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-06T05:48:00.000Z","updated_at":"2025-09-02T05:02:12.000Z","dependencies_parsed_at":"2025-02-23T10:18:38.873Z","dependency_job_id":"11a1d35c-18e3-438c-80bb-744019165bd2","html_url":"https://github.com/yegor256/donce","commit_stats":null,"previous_names":["yegor256/donce"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/yegor256/donce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fdonce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fdonce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fdonce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fdonce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/donce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fdonce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278327165,"owners_count":25968895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automated-testing","docker","ruby","testing","unit-testing"],"created_at":"2025-03-04T12:29:15.164Z","updated_at":"2025-10-04T14:41:35.467Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Builds Docker image, runs it, and kills\n\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/donce)](https://www.rultor.com/p/yegor256/donce)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/donce/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/donce/actions/workflows/rake.yml)\n[![PDD status](https://www.0pdd.com/svg?name=yegor256/donce)](https://www.0pdd.com/p?name=yegor256/donce)\n[![Gem Version](https://badge.fury.io/rb/donce.svg)](https://badge.fury.io/rb/donce)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/donce.svg)](https://codecov.io/github/yegor256/donce?branch=master)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/donce/master/frames)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/donce)](https://hitsofcode.com/view/github/yegor256/donce)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/donce/blob/master/LICENSE.txt)\n\nThis small Ruby library helps to build temporary [Docker]\nimages, run Docker containers, and clean up afterwards — it may be\nconvenient for automated tests (for example, with [Minitest]):\n\n```ruby\nclass MyTest \u003c Minitest::Test\n  def test_prints_hello_world\n    stdout = donce(\n      dockerfile: '\n        FROM ubuntu\n        CMD echo \"Hello, world!\"\n      '\n    )\n    assert_equal(\"Hello, world!\\n\", stdout)\n  end\nend\n```\n\nIt's possible to run a Docker image in background mode too:\n\n```ruby\nstdout = donce(image: 'ubuntu', command: 'sleep 9999') do |id|\n  # The \"id\" is the container id\n  # The \"donce_host()\" is the hostname of it\nend\n```\n\nIf you set `DONCE_SUDO` environment variable to `true`, `docker` will\nbe executed via `sudo`.\n\n## Parameters\n\nHere's a list of the available parameters for `donce`:\n\n* `dockerfile`: Content of the Dockerfile (string or array of strings)\n* `home`: Directory with Dockerfile and all other necessary files\n* `image`: Name of a Docker image to use (e.g. \"ubuntu:22.04\")\n* `log`: Logging destination (defaults to $stdout)\n* `args`: Extra arguments for the docker command\n* `env`: Environment variables mapping for the container\n* `volumes`: Local to container volumes mapping\n* `ports`: Local to container port mapping\n* `build_args`: Arguments for docker build (--build-arg)\n* `root`: Let user inside the container be \"root\" (default: false)\n* `command`: The command to execute in the container\n* `timeout`: Maximum seconds to spend on each docker call (default: 10)\n\nThe function `donce_host()` returns the hostname of the host machine that\ncan be used from within the container.\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 3.0+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n\n[Docker]: https://www.docker.com/\n[Minitest]: https://github.com/minitest/minitest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fdonce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fdonce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fdonce/lists"}