PHP, Symfony and MongoDB configuration for Bitbucket pipelines and run tests on every commit
Read this in other languages: English, Español.
Bitbucket pipeline configuration to run phpunit tests on every commit to a PHP, Symfony project using MongoDB.
In this repository you'll find the file bitbucket-pipelines.yml
responsible to pull the docker image and run the pipeline.
You'll also find Dockerfile
the file used to create our custom image.
In our case we need PHP 5.6 and MongoDB 3.2. In the same image you'll find installed composer for installing the dependencies in your PHP+Symfony project and PHPUnit 5.6 to run PHP 5.6 tests.
You can use the Dockerfile
available as a base for your custom image and modify it accordingly. For instance, using PHP 7:
FROM php:7.1.1
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
mongodb \
mongodb-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Once you have your image ready, buid it:
docker build -t <your-docker-account>/php-mongodb .
docker run -i -t <your-docker-account>/php-mongodb /bin/bash
- Use your credentials to login in Docker Hub.
docker login
- Push your new image.
docker push <your-docker-account>/php-mongodb
For a detailed explanation, please refer to: https://moisesbm.wordpress.com/2019/05/08/bitbucket-pipeline-configuration-for-php-mongodb-and-symfony/
Moisés Belchín
@moises_b_m
https://github.com/mbelchin/
Distributed under the MIT license. See LICENSE
for more information.
This project was created to find a simple way to share same BitBucket pipeline configuration to be used in projects using PHP and Symfony which need MongoDB as database to run phpunit tests.
If you consider some things could be improved or you know another simpler, easier configurable tools, please open a discussion thread so all of us could benefit from those improvements.
- Fork it (https://github.com/mbelchin/bitbucket-pipelines-php-symfony-mongodb/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am '<type>(scope): add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request