Skip to content

Commit

Permalink
added development environment
Browse files Browse the repository at this point in the history
  • Loading branch information
1ma committed Jun 21, 2016
1 parent 66e3721 commit f791770
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/app/config/parameters.yml
/build/
/docker-compose.yml
/phpunit.xml
/var/*
!/var/cache
Expand Down
9 changes: 1 addition & 8 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,12 @@ twig:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
driver: pdo_pgsql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"

orm:
auto_generate_proxy_classes: "%kernel.debug%"
Expand Down
10 changes: 5 additions & 5 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
database_host: db
database_port: 5432
database_name: docker-symfony
database_user: docker
database_password: docker
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"

Expand Down
Binary file added doc/img/config-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/config-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/config-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/config-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/config-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/config-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/debug-tests-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/debug-tests-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/debug-web-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/debug-web-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/run-tests-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions etc/docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MAKEFILE_ABS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

.PHONY: dev
dev:
cp -up $(MAKEFILE_ABS_DIR)dev/docker-compose.yml.dist $(MAKEFILE_ABS_DIR)../../docker-compose.yml
25 changes: 25 additions & 0 deletions etc/docker/dev/docker-compose.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '2'
services:
web:
image: nginx:1.11-alpine
depends_on:
- app
ports:
- "80:80"
volumes:
- ./etc/docker/dev/web:/etc/nginx/conf.d
volumes_from:
- app
app:
image: 1maa/php-dev:7.0
ports:
- "4444:22"
volumes:
- .:/var/www/docker-symfony.dev
working_dir: /var/www/docker-symfony.dev
db:
image: 1maa/postgres-dev:9.5
volumes:
- db_data:/var/lib/postgres/9.5
volumes:
db_data: ~
23 changes: 23 additions & 0 deletions etc/docker/dev/web/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
server_name docker-symfony.dev;

root /var/www/docker-symfony.dev/web;

location / {
try_files $uri /app_dev.php$is_args$args;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}

location ~ \.php$ {
return 404;
}
}
66 changes: 66 additions & 0 deletions src/AppBundle/Entity/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* Product
*
* @ORM\Table(name="products")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
class Product
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;

/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true)
*/
private $name;


/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* Set name
*
* @param string $name
*
* @return Product
*/
public function setName($name)
{
$this->name = $name;

return $this;
}

/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
}

9 changes: 9 additions & 0 deletions src/AppBundle/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

class ProductRepository extends EntityRepository
{
}
3 changes: 2 additions & 1 deletion web/app_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|| (!substr(@$_SERVER['REMOTE_ADDR'], 0, 4) === '172.' &&
!(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server'))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
Expand Down

0 comments on commit f791770

Please sign in to comment.