Skip to content

Commit

Permalink
Merge pull request #260 from sven-ahrens/feature/add-docker-setup
Browse files Browse the repository at this point in the history
[Feature]: Add docker setup and an updated README for people who want to contribute
  • Loading branch information
alexislefebvre authored Jan 28, 2024
2 parents f282770 + e7db9a5 commit d355398
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: acme
ports:
- 3306:3306
Expand Down Expand Up @@ -112,6 +112,9 @@ jobs:
- name: Show Composer dependencies
run: composer show

- name: Set up hosts file
run: echo '127.0.0.1 mariadb postgres' | sudo tee -a /etc/hosts

- name: Run tests
# In phpunit.xml.dist, tests annotated with "@group mysql" are excluded, revert this
# Run tests twice to ensure that tests are idempotent even if database caching is enabled
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM php:8.3-fpm
WORKDIR "/application"

RUN apt-get update \
&& apt-get -y --no-install-recommends install \
libpq-dev \
libsqlite3-dev \
unzip \
wget \
default-mysql-client \
&& docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Documentation
* [Events](doc/events.md)
* [Examples](doc/examples.md)
* [Caveats](doc/caveats.md)
* [Contributing](doc/contributing.md)
25 changes: 25 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributing
This is for people who want to contribute to the project.

## How to get started

First of all, you need to fork the repository and clone it locally.
After that, we've prepared a docker setup to help you get started quickly.

Install docker and docker-compose on your machine, then run the following commands:

```bash
docker-compose up --detach
```

Install the dependencies with composer:

```bash
docker-compose exec php-fpm composer install
```

Now you can execute the tests with the following command:

```bash
docker-compose exec php-fpm ./vendor/bin/phpunit --exclude-group ""
```
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.1'
services:
mariadb:
image: 'mariadb:11.0'
working_dir: /application
volumes:
- '.:/application'
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=acme
ports:
- '11003:3306'

postgres:
image: 'postgres:15-alpine'
working_dir: /application
volumes:
- '.:/application'
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- POSTGRES_HOST=postgres
ports:
- '11004:5432'

php-fpm:
build: .
working_dir: /application
volumes:
- '.:/application'
6 changes: 3 additions & 3 deletions tests/AppConfigMysql/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
doctrine:
dbal:
driver: pdo_mysql
host: 127.0.0.1
port: null
host: mariadb
port: 3306
dbname: acme
user: root
password: ""
password: root
2 changes: 1 addition & 1 deletion tests/AppConfigMysqlUrl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

doctrine:
dbal:
url: 'mysql://root:@127.0.0.1:3306/foobar'
url: 'mysql://root:root@mariadb:3306/foobar'
driver: pdo_mysql
2 changes: 1 addition & 1 deletion tests/AppConfigPgsql/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
doctrine:
dbal:
driver: pdo_pgsql
host: 127.0.0.1
host: postgres
port: 5432
dbname: postgres
user: postgres
Expand Down

0 comments on commit d355398

Please sign in to comment.