This is a simple To-do list application with GUI and REST API written in Symfony, running on multiple Docker containers. Docker Compose is used for orchestration.
- If you are looking for products example rather than to-do list,
check the
products
tag. - If you are looking for a multiple containers example with Apache,
check the
apache
tag. - If you are looking for a single container example with supervisor and Vagrant,
check the
single-container
tag.
This environment uses 3 containers:
- The
php
container with PHP-FPM, being build fromDockerfile
. It's based onsskorc/symfony2-mongo
image. You can find itsDockerfile
in this repo. This container shares the application sources with the host machine. - The
nginx
container with nginx, pulled directly from the official nginx image on Docker Hub. This container shares the application sources with the host machine. - The
db
container with MongoDB, pulled directly from the official MongoDB image on Docker Hub. This container shares DB data with the Docker Machine VM.
Containers are managed by Docker Compose. The configuration is in the docker-compose.yml
.
Basically, you need to have Docker Compose installed.
If you use Mac OS X or Windows as your host OS, I recommend using Docker Machine as the proxy VM to run Docker.
In the project root directory run the following command:
docker-compose up -d
This command will build the php
Docker image and run its container together with nginx
and db
containers.
-
Log in to the
php
container by running the following command:docker exec -it dockersymfony_php_1 bash
-
Install dependencies by running the following command:
cd /var/www/docker-symfony && composer install -n
-
Change
/tmp
dir permissions:chown -R www-data:www-data /tmp
-
Check Docker Machine IP address:
docker-machine ip dev
. -
Assuming it's 192.168.99.100, add the following line to your
/etc/hosts
file:192.168.99.100 docker-symfony.dev
TBA
-
Check Docker Machine IP address:
docker-machine ip dev
. -
Assuming it's 192.168.99.100, add the following line to your
%SystemRoot%\System32\drivers\etc\hosts
file:192.168.99.100 docker-symfony.dev
You can test the application by following http://docker-symfony.dev/ URL in your browser.
-
You can test the REST API by sending the POST request with the
name
parameter tohttp://docker-symfony.dev/api/tasks
. Example:curl -w "\n" -H "Content-Type: application/json" -X POST -d '{"name":"Hello!"}' http://docker-symfony.dev/api/tasks
-
You can get all products by sending the GET request to
http://docker-symfony.dev/api/tasks
. Example:curl -w "\n" -X GET http://docker-symfony.dev/api/tasks
This application is ready to be debugged by Xdebug. If you want to configure your host and PHPStorm to debug this app, please follow the instruction.
The application is being build on Travis CI and it's being deployed to Docker Cloud.