{"id":15040622,"url":"https://github.com/qgadrian/compox","last_synced_at":"2025-07-01T16:07:53.552Z","repository":{"id":57485119,"uuid":"210677833","full_name":"qgadrian/compox","owner":"qgadrian","description":"🏁 Auto start  Docker containers before running your tests","archived":false,"fork":false,"pushed_at":"2025-03-07T12:29:45.000Z","size":74,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T18:50:49.543Z","etag":null,"topics":["docker-compose","docker-container","docker-testing","elixir-lang","testing"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qgadrian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-09-24T19:06:07.000Z","updated_at":"2025-03-07T12:29:42.000Z","dependencies_parsed_at":"2025-01-20T10:29:53.511Z","dependency_job_id":"2809a285-b114-4f46-a8c2-dc128fdf1952","html_url":"https://github.com/qgadrian/compox","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/qgadrian/compox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qgadrian%2Fcompox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qgadrian%2Fcompox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qgadrian%2Fcompox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qgadrian%2Fcompox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qgadrian","download_url":"https://codeload.github.com/qgadrian/compox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qgadrian%2Fcompox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262996403,"owners_count":23396903,"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","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":["docker-compose","docker-container","docker-testing","elixir-lang","testing"],"created_at":"2024-09-24T20:44:50.075Z","updated_at":"2025-07-01T16:07:53.535Z","avatar_url":"https://github.com/qgadrian.png","language":"Elixir","readme":"[![Hex version](https://img.shields.io/hexpm/v/sippet.svg \"Hex version\")](https://hex.pm/packages/compox)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-9768d1.svg)](https://hexdocs.pm/compox)\n\n# Compox\n\n## Introduction\n\nCompox ensure your whole infrastructure is up before running the tests.\n\nCompox helps you to setup an ephemeral environment to run your tests using the\n`docker-compose.yml` present in your project. After all your tests are done,\nit will take the test environment down. This way your machine won't waste\nresources having the containers running when they are not needed.\n\n## Features\n\n- Reuse created/running containers for other projects (e.g. shared database)\n- Automatic start of the required container services\n- Automatic stop of the required container services\n\n## Installation\n\nAdding `compox` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:compox, \"~\u003e 0.1.0-rc3\", only: [:test]}\n  ]\nend\n```\n\n## Usage\n\nTo use Compox follow these steps:\n\n- Create a `docker-compose.yml` file with the containers that will be started\n  by this application.\n\n- Ensure Compox starts all containers before running the tests:\n\n```elixir\ndefp aliases do\n  [\n    test: [\"compox.up\", \"ecto.create --quiet\", \"ecto.migrate --quiet\", \"test\"]\n  ]\nend\n```\n\n- Edit your `test_helper.exs` to stop the containers after the tests are\n  done:\n\n```elixir\nExUnit.after_suite(fn _ -\u003e\n  Compox.stop()\nend)\n```\n\n### Upchecks\n\nSometimes a container is started by it takes a while to be ready to be used by\nyour application. For example, a database container can be started by the\ndatabase will take few seconds to start accepting connections.\n\nTo avoid any errors, Compox supports _upchecks_ probe configurations to validate\nwhether a container can be used or not.\n\nYou can implement your own logic to validate if a container is ready (see\nexample below) or use the default provided upchecks:\n\n* `Postgres`: `Compox.Upchecks.Postgrex`\n\n### Example\n\nCompox allows you to configure a project to start/stop the containers to run the\ntests, but also provides configuration to **work with any kind of situation**.\n\nFor example, some of or coworkers prefer to have the containers running all the\ntime. In this case you want to ensure the docker containers are started before the test, so people that prefer to save resources will start the containers, but you will also won't to avoid to take containers down.\n\nYou `config/test.exs` file will look like:\n\n```elixir\nuse Mix.Config\n\nconfig :compox,\n  auto_start: true,\n  auto_stop: false,\n  exclude: [\"a_service_should_not_be_started\"],\n  container_upchecks: [\n    \"postgres-service\": {Compox.Upchecks.Postgrex, []},\n    another_service: fn -\u003e\n      Another.Connection.up?()\n    end\n  ]\n```\n\nThe people who will want to stop the containers after test can use a [_dotenv_\nlibrary](https://github.com/BlakeWilliams/envy) to change the `auto_stop` config to `true` on their machines.\n\n\u003e This can work the other way around, start/stopping the containers always and\n\u003e having `dotfile` config to skipping the start/stop.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqgadrian%2Fcompox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqgadrian%2Fcompox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqgadrian%2Fcompox/lists"}