Docker running Nginx, PHP-FPM, Mongo.
THIS ENVIRONMENT SHOULD ONLY BE USED FOR DEVELOPMENT!
DO NOT USE IT IN PRODUCTION!
-
Download it :
$ git clone https://github.com/nanoninja/docker-nginx-php-mongo.git
-
Run :
$ docker-compose up -d
-
Open your favorite browser :
- http://localhost:8000
- https://localhost:3000 (HTTPS not configured by default)
docker-nginx-php-mongo
├── README.md
├── bin
│ └── linux
│ └── clean.sh
├── data
│ └── db
│ ├── dumps
│ └── mongo
├── docker-compose.yml
├── etc
│ ├── nginx
│ │ └── default.conf
│ ├── php
│ │ └── php.ini
│ └── ssl
└── web
├── app
│ ├── composer.json
│ ├── phpunit.xml.dist
│ ├── src
│ │ └── Foo.php
│ └── test
│ ├── FooTest.php
│ └── bootstrap.php
└── public
└── index.php
Edit etc/php/php.ini file and add your ip address :
xdebug.remote_host=192.168.0.1
docker run --rm -v $(pwd)/web/app:/app -v ~/.ssh:/root/.ssh composer/composer update
<?php
$manager = new MongoDB\Driver\Manager("mongodb://mongo:27017/test");
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['name' => 'John Doe']);
$writeConcern = new MongoDB\Driver\writeConcern(MongoDB\Driver\WriteConcern::MAJORITY, 100);
$result = $manager->executeBulkWrite('test.mycollection', $bulk);
var_dump($result);
?>
docker exec -it mongo bash
mongoexport --port 27020 --db test --collection mycollection --out $(pwd)/data/db/dumps/mycollection.json
mongodump --port 27020 --db test --collection mycollection --out $(pwd)/data/db/dumps
-
Generate certificates
$ docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=localhost" jacoelho/generate-certificate
-
Configure Nginx
Edit nginx file etc/nginx/default.conf and uncomment the server section.
# server { # ... # }
./web/app/vendor/apigen/apigen/bin/apigen generate -s web/app/src -d web/app/doc
Warning: Clears all containers and volumes.
$ ./bin/linux/clean.sh $(pwd)