From c645e01dc337e06387ea8d421b49492a7493e024 Mon Sep 17 00:00:00 2001 From: Olivier Laviale Date: Fri, 15 Apr 2022 03:40:55 +0200 Subject: [PATCH] Add Docker support for local development --- CONTRIBUTING.md | 28 ++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++++++ Makefile | 10 ++++++++++ README.md | 6 ++++++ docker-compose.yaml | 25 +++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ed6eaf4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +We accept contributions via Pull Requests on [Github](https://github.com/ICanBoogie/Inflector). + +## Pull Requests + +- **Add tests!** — Your contribution won't be accepted if it doesn't have tests. +- **Document any change in behaviour** — Make sure the `README.md` and any other relevant documentation are kept + up-to-date. +- **Consider our release cycle** — We follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not + an option. +- **Create feature branches** — We won't pull from your main branch. +- **One pull request per feature** — If you want to do more than one thing, send multiple pull requests. +- **Send coherent history** — Make sure each individual commit in your pull request is meaningful. If you had to make + multiple intermediate commits while developing, please [squash them][git-squash] before submitting. + +## Running Tests + +We provide a Docker container for local development. Run `make test-container` to create a new session. Inside the +container run `make test` to run the test suite. Alternatively, run `make test-coverage` for a breakdown of the code +coverage. The coverage report is available in `build/coverage/index.html`. + +**Thanks for your contribution**! + + +[git-squash]: http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f2e62ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +ARG PHP_VERSION +FROM php:${PHP_VERSION}-cli-alpine + +RUN apk add --no-cache make && \ + docker-php-ext-enable opcache && \ + docker-php-source delete + +RUN echo $'\ +display_errors=On\n\ +error_reporting=E_ALL\n\ +date.timezone=UTC\n\ +' >> /usr/local/etc/php/conf.d/php.ini + +ENV COMPOSER_ALLOW_SUPERUSER 1 + +RUN curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \ + mv composer.phar /usr/local/bin/composer && \ + echo $'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.profile diff --git a/Makefile b/Makefile index f13be6b..f500375 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,13 @@ test-coverage: test-dependencies test-coveralls: test-dependencies @mkdir -p build/logs @$(PHPUNIT) --coverage-clover build/logs/clover.xml + +.PHONY: test-container-56 +test-container-56: + @docker-compose run --rm app56 sh + @docker-compose down + +.PHONY: test-container-74 +test-container-74: + @docker-compose run --rm app74 sh + @docker-compose down diff --git a/README.md b/README.md index 51aedcc..2227eb3 100644 --- a/README.md +++ b/README.md @@ -381,6 +381,12 @@ The project is continuously tested by [GitHub actions](https://github.com/ICanBo +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + + + ## License **ICanBoogie/DateTime** is released under the [BSD-3-Clause](LICENSE). diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..190188e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,25 @@ +--- +version: "3.0" +services: + app56: + build: + context: . + args: + PHP_VERSION: 5.6 + environment: + PHP_IDE_CONFIG: "serverName=icanboogie-datetime" + volumes: + - .:/app:delegated + - ~/.composer:/root/.composer:delegated + working_dir: /app + app74: + build: + context: . + args: + PHP_VERSION: 7.4 + environment: + PHP_IDE_CONFIG: "serverName=icanboogie-datetime" + volumes: + - .:/app:delegated + - ~/.composer:/root/.composer:delegated + working_dir: /app