Skip to content

Commit

Permalink
add docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
jeslopcru committed Nov 11, 2016
1 parent 0bba1ab commit ca7f71c
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Makefile
@@ -0,0 +1,20 @@
help: ## Prints this help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

up: ## Builds the docker containers and installs dependencies
docker-compose up -d

stop: ## stops the docker containers
docker-compose stop

down: ## destroy all container
docker-compose down

composer: ## run composer command using: make composer argument=install
docker exec -it jedy-php-fpm php composer.phar

log: ## see prod logs
tail -f $(PWD)/var/logs/prod.log

install: ## Install database
docker exec -it jedy-php-fpm php bin/console doctrine:schema:create
4 changes: 2 additions & 2 deletions app/config/parameters.yml.dist
Expand Up @@ -5,8 +5,8 @@ parameters:
database_host: 127.0.0.1
database_port: ~
database_name: jedy
database_user: root
database_password: ~
database_user: jedy
database_password: jedy
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"

Expand Down
Binary file added composer.phar
Binary file not shown.
35 changes: 35 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,35 @@
###############################################################################
# Generated on phpdocker.io #
###############################################################################

jedy-mysql:
image: mysql:5.7
container_name: jedy-mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=qwerty
- MYSQL_DATABASE=jedy
- MYSQL_USER=jedy
- MYSQL_PASSWORD=jedy

jedy-webserver:
image: phpdockerio/nginx:latest
container_name: jedy-webserver
volumes:
- .:/var/www/jedy
- ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- 80:80
links:
- jedy-php-fpm

jedy-php-fpm:
build: .
dockerfile: .docker/php-fpm/Dockerfile
container_name: jedy-php-fpm
volumes:
- .:/var/www/jedy
- ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-overrides.ini
links:
- jedy-mysql
43 changes: 43 additions & 0 deletions docker/nginx/nginx.conf
@@ -0,0 +1,43 @@
server {
listen 80 default;

client_max_body_size 108M;

access_log /var/log/nginx/jedy.access.log;

root /var/www/jedy/web;

rewrite ^/app\.php/?(.*)$ /$1 permanent;

try_files $uri @rewriteapp;

location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}

# Deny all . files
location ~ /\. {
deny all;
}

location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_pass jedy-php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index app.php;
send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/jedy_php_errors.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
}

# Statics
location /(bundles|media) {
access_log off;
expires 30d;
try_files $uri @rewriteapp;
}

}
9 changes: 9 additions & 0 deletions docker/php-fpm/Dockerfile
@@ -0,0 +1,9 @@
FROM phpdockerio/php7-fpm:latest

# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.0-mysql php7.0-xdebug \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*


WORKDIR "/var/www/jedy"
2 changes: 2 additions & 0 deletions docker/php-fpm/php-ini-overrides.ini
@@ -0,0 +1,2 @@
upload_max_filesize = 100M
post_max_size = 108M
2 changes: 1 addition & 1 deletion web/app_dev.php
Expand Up @@ -12,7 +12,7 @@
// 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')
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1','192.168.99.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 ca7f71c

Please sign in to comment.