-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker Development Kickstart #1053
Conversation
@Matt3o12 I'd like to help out with this issue. How can I help? |
@westonplatter Well, first of all, you could tell me whether your not, you are interested in this pull request. I found this docker file incredible helpful for setting up a test environment for the development of this project (because I did not have to install any dependency on my computer). I also believe other might find this helpful because settings up the test environment is incredible easy using docker if you are familiar with it. Secondly, you can create a repository "robmorgan/phinx" on docker hub to host the image. This would speed up the first time the tests are run under docker. I can assist you with creating an automated build process so that the image is always up-to-date and you there is no maintenance. Please only do this if you are at least a maintainer of this project so this image can be official and trusted. Lastly, if this is merged I could look into ways to also set up the docker-developemtn environment (this is this pull requests) for Microsoft SQL server tests (this would work on Linux, macOS, and Windows without having to install windows). This is thanks to the now official Linux support for Microsoft SQL Server. But I cannot guarantee if I am even able to do that because I am not familiar with MSSQL (though, I will try my best if there is interest and I have some spare time). Please keep in mind that this will not replace the automated Travis tests and they will always be more accurate because the project would be tested against all Php versions. Using my method, tests are only run for PHP 5.4 (because it is the oldest -- read my official pull requests for more information). This is rather a more convenient method for getting started with contributing to phinx. |
@@ -0,0 +1,18 @@ | |||
FROM centos:7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you did not use official PHP image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@newPOPE If I merge this pull request would you volunteer to send a new PR changing it to use the official image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a pleasure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@newPOPE great, feel free to improve anything after this is merged. I also agree the entrypoint is too complex
--prefer-lowest | ||
|
||
WORKDIR /app/ | ||
ENTRYPOINT ["/bin/bash", "/usr/local/bin/entrypoint.bash"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is really necessary use that complex entrypoint? From my point of view (after different project migrated to Docker development) is better switch devs directly to the command line when common commands are present.
Something like docker-compose run phinx bash
and there is prepared tools like composer
and others.
On the other side you can use composer scripts for that commands.
Thanks a lot @Matt3o12 |
@newPOPE Now it's your turn :) |
Sorry for taking so long to answer. Here are my reasons why I used centos instead of the official PHP image: the official image no longer maintains a PHP 5.4. In fact, PHP 5.6 is their oldest maintained image means that the image for the old systems are insecure and might put developers machines at harm (though it would take quite a lot of work to exploit that). Furthermore they might delete the tag later which might break the dockerfile or a security update changes PHP's API and breaks phinx (unlikely but could happen). Since I would expect contributes to also work for the oldest supported PHP version, i chose centos since they are the only "modern" distro which still supports such an ancient PHP version (and they also support their distro for a very long time, so things should not break for a while). Secondly, I chose such a complicated entry point because of composer. When having a slow internet connection, composer takes forever to build the vendor dir. Ideally, we would publish the docker image, which already contains the vendor dir. Pulling a docker image with the vendor dir prepacked is so much quicker then using composer install (at least for me). We can setup docker hub to automatically build a new image with the updated dependencies for push to the main branch. My entry point just copies vendor dir if it doesn’t exist already. Furthermore, a different configuration file is automatically used, which is configured for Postgres, MySQL and SQLite. This is necessary because the database runs in another container. |
@Matt3o12 thank you for clarifying. You can see PR #1139 for simplifying Docker dev environment.
We can move discussion about Docker to that issue. |
When I was trying to contribute to phinx, I found it rather difficult to setup the testing environment for running the unit tests.
This is why I have decided to create docker and docker-compose files to help you kickstart a development environment.
The advantage of using docker for developing is that running
docker-compose run phinx
will bring up a freshly created MySQL 5.5 and Postgres 9.2 database (the versions can be easily adjusted indocker-compose.yml
), and a PHP 5.4 container running the unit tests. The PHP 5.4 container uses CentOS 7. I chose CentOS 7 since it still supports (and maintains PHP 5.4, unlike the official docker image) and I chose PHP 5.4 because it is the oldest PHP version supported by phinx.So, what this does is: it will download & install all depencies (mysql, postgres, sqlite-lib, php, git and a few others), download all php composer packages (using --prefer-stable --prefer-source --prefer-lowest), and then run the tests, just with one command.
Besides being able to easily test it against every database, the database containers are volatile which means once they are removed (docker-compose down), they loose all data (this is helpful if you manage to corrupt the database because recreating it is really easy). They also isolate your other database (security warning: docker does not provide secure isolation to the host os, which means that there might be zero-days, so do not run any untrusted code inside docker. It will, however, save you from an accidental
DROP DATABASE myOtherDatabase
).Things to do (can be done in another merge):