Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
Add a code snippet to allow dockerized applications run in dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
burahimu committed Jan 3, 2017
1 parent cf25579 commit 10ca263
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ A set of docker resources to get quickly started on a symfony project
Getting started
---------------

* Copy the **docker** directory, the **docker-compose.yml** and **Makefile** in your symfony project.
* Copy the `docker` directory, the `docker-compose.yml` and `Makefile` in your symfony project.
* Edit the volumes, environment and container_name values in the docker-compose.yml according to your needs. (Do not use special chars in mysql env variables except underscores)
* Edit the Makefile variables
* Update `app_dev.php` to allow dockerized applications. See the condition snippet in `app_dev_docker_condition_snippet.php`.

Then run your containers:

Expand All @@ -23,7 +24,7 @@ Benefit

* Easily change your php version from the docker-compose file
* Use the makefile to auto complete daily commands
* Display all logs (proxy, nginx, php) with the **docker-compose logs -f command**.
* Display all logs (proxy, nginx, php) with the `docker-compose logs -f command`.

Todo
----
Expand Down
14 changes: 14 additions & 0 deletions app_dev_docker_condition_snippet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

// The following snippet allows app_dev.php for dockerized applications.
// You need to replace your actual condition in /your/project/web/app_dev.php

$dockerized = (bool) strstr($_SERVER['REMOTE_ADDR'], '172.');

if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !$dockerized
|| !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) && !$dockerized
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

0 comments on commit 10ca263

Please sign in to comment.