{"id":18986855,"url":"https://github.com/karllhughes/docker-testing-examples","last_synced_at":"2025-04-19T20:44:55.735Z","repository":{"id":77520001,"uuid":"130230552","full_name":"karllhughes/docker-testing-examples","owner":"karllhughes","description":"Examples of using Docker to improve your test suite","archived":false,"fork":false,"pushed_at":"2018-04-24T21:53:17.000Z","size":7141,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:12:08.504Z","etag":null,"topics":["docker","nighthawk","nodejs","phpunit","testing"],"latest_commit_sha":null,"homepage":"https://blog.codeship.com/7-ways-to-improve-your-test-suite-with-docker/","language":"Visual Basic","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/karllhughes.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}},"created_at":"2018-04-19T14:45:25.000Z","updated_at":"2023-06-08T12:27:35.000Z","dependencies_parsed_at":"2023-03-17T10:00:55.459Z","dependency_job_id":null,"html_url":"https://github.com/karllhughes/docker-testing-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karllhughes%2Fdocker-testing-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karllhughes%2Fdocker-testing-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karllhughes%2Fdocker-testing-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karllhughes%2Fdocker-testing-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karllhughes","download_url":"https://codeload.github.com/karllhughes/docker-testing-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249795636,"owners_count":21326780,"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","nighthawk","nodejs","phpunit","testing"],"created_at":"2024-11-08T16:37:12.757Z","updated_at":"2025-04-19T20:44:55.703Z","avatar_url":"https://github.com/karllhughes.png","language":"Visual Basic","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enhancing Your Test Suite with Docker - Examples\n\nThis repository includes examples of how you can improve your test suite with Docker. Examples are in PHP or Node, and require you to have Docker installed locally.\n\nUse the short instructions below, or check out the blog post (coming soon) for more details.\n\n## Ex 1: Running PHPUnit tests in older version of PHP\n\n- Navigate to `/ex-1` directory\n- Install dependencies (using Docker and Composer): `docker run --rm -v $(pwd):/app -w /app composer install`\n- Run PHPUnit in PHP 7.2: `docker run --rm -v $(pwd):/app -w /app php:7.2 vendor/bin/phpunit index.php` (should pass)\n- Run PHPUnit in PHP 7.1: `docker run --rm -v $(pwd):/app -w /app php:7.1 vendor/bin/phpunit index.php` (should pass)\n- Run PHPUnit in PHP 7.0: `docker run --rm -v $(pwd):/app -w /app php:7.0 vendor/bin/phpunit index.php` (should pass)\n- Run PHPUnit in PHP 5.6: `docker run --rm -v $(pwd):/app -w /app php:5.6 vendor/bin/phpunit index.php` (should throw syntax error)\n\n## Ex 2: Connecting to MySQL when missing database extension\n\n- Navigate to `/ex-2` directory\n- Install dependencies (using Docker and Composer): `docker run --rm -v $(pwd):/app -w /app composer install`\n- Run a MySQL container to test connections on: `docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql:5.7`\n- Run PHPUnit in PHP 7.2: `docker run --rm -v $(pwd):/app -w /app --link database php:7.2 vendor/bin/phpunit index.php` (should fail)\n- Build a custom image from Dockerfile (with mysqli extension): `docker build . -t php-72-mysqli`\n- Run PHPUnit using custom image: `docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php` (should pass)\n- Stop/remove the MySQL container when you're done: `docker rm -f database`\n\n## Ex 3: Integration test with different versions of MySQL\n\n- Navigate to `/ex-3` directory\n- Install dependencies (using Docker and Composer): `docker run --rm -v $(pwd):/app -w /app composer install`\n- Build the PHP/mysqli image from Dockerfile (same as in Ex 2): `docker build . -t php-72-mysqli`\n- Run a MySQL 5.6 container to test with: `docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=test mysql:5.6`. Wait a few seconds for the container to boot.\n- Run PHPUnit using custom image: `docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php` (should fail)\n- Stop/remove the MySQL container: `docker rm -f database`\n- Run a MySQL 5.7 container to test with: `docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=test mysql:5.7`. Wait a few seconds for the container to boot.\n- Run PHPUnit using custom image: `docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php` (should pass)\n- Stop/remove the MySQL container when you're done: `docker rm -f database`\n\n## Ex 4: Seeding data with volumes\n\n- Navigate to `/ex-4` directory\n- Install dependencies (using Docker and Composer): `docker run --rm -v $(pwd):/app -w /app composer install`\n- Build the PHP/mysqli image from Dockerfile (same as in Ex 2): `docker build . -t php-72-mysqli`\n- Run a MySQL container with a bind mount: `docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -v $(pwd)/data:/var/lib/mysql mysql:5.7`. Wait a few seconds for the container to boot.\n- Run PHPUnit using custom image: `docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php` (should pass)\n- Stop/remove the MySQL container when you're done: `docker rm -f database`\n\n## Ex 5: NodeJS End-to-end tests\n\n- Navigate to `/ex-5` directory\n- Run the tests with [Docker Compose](https://docs.docker.com/compose/): `docker-compose run --rm nightwatch`.\n- Stop the containers: `docker-compose down`.\n\nThis example adapted from [blueimp's open source nightwatch repo](https://github.com/blueimp/nightwatch).\n\n## Ex 6: End-to-end test for networked application\n\n- Navigate to `/ex-6` directory\n- Run the tests with [Docker Compose](https://docs.docker.com/compose/): `docker-compose run --rm nightwatch`.\n- Stop the containers: `docker-compose down`.\n\nThis example adapted from [b00giZm's open source Node/Express example](https://github.com/b00giZm/docker-compose-nodejs-examples/tree/master/00-basic-express-generator).\n\n## Ex 7: Automating with Codeship\n\n\n# Legal\n\nCopyright 2018, Karl Hughes\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarllhughes%2Fdocker-testing-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarllhughes%2Fdocker-testing-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarllhughes%2Fdocker-testing-examples/lists"}