From 540ef5e084db2295d7ca476c980ec10fb90e9722 Mon Sep 17 00:00:00 2001 From: Fabien MEURILLON Date: Sat, 9 Jan 2016 14:47:32 +0100 Subject: [PATCH] Add basic docker-compose configuration --- .gitignore | 3 ++ docker-compose.yml | 17 ++++++++ docker/nginx/nginx.conf | 89 +++++++++++++++++++++++++++++++++++++++++ docker/php/Dockerfile | 10 +++++ 4 files changed, 119 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/nginx/nginx.conf create mode 100644 docker/php/Dockerfile diff --git a/.gitignore b/.gitignore index 9bde27db..0495cb17 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ # Data for wallabag data/assets/* data/db/wallabag*.sqlite + +# Docker container logs +docker/logs/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..bc469419 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +nginx: + image: nginx + ports: + - "8080:80" + volumes: + - ./docker/nginx/nginx.conf:/nginx.conf + - ./docker/logs/nginx:/var/log/nginx + - .:/var/www/html + links: + - php:php + command: nginx -c /nginx.conf +php: + build: docker/php + ports: + - "9000:9000" + volumes: + - .:/var/www/html diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 00000000..7e82a0f8 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,89 @@ +user nginx; +worker_processes 1; +pid /var/run/nginx.pid; + +events { + worker_connections 2048; + multi_accept on; + use epoll; +} + +http { + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + server_tokens off; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 15; + types_hash_max_size 2048; + include /etc/nginx/mime.types; + default_type application/octet-stream; + access_log off; + error_log off; + gzip on; + gzip_disable "msie6"; + open_file_cache max=100; + + + upstream php-upstream { + server php:9000; + } + + server { + #server_name domain.tld www.domain.tld; + root /var/www/html/web; + + location / { + # try to serve file directly, fallback to app.php + try_files $uri /app.php$is_args$args; + } + # DEV + # This rule should only be placed on your development environment + # In production, don't include this and don't deploy app_dev.php or config.php + location ~ ^/(app_dev|config)\.php(/|$) { + fastcgi_pass php-upstream; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + } + # PROD + location ~ ^/app\.php(/|$) { + fastcgi_pass php-upstream; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + # When you are using symlinks to link the document root to the + # current version of your application, you should pass the real + # application path instead of the path to the symlink to PHP + # FPM. + # Otherwise, PHP's OPcache may not properly detect changes to + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 + # for more information). + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + # Prevents URIs that include the front controller. This will 404: + # http://domain.tld/app.php/some-path + # Remove the internal directive to allow URIs like this + internal; + } + + error_log /var/log/nginx/project_error.log; + access_log /var/log/nginx/project_access.log; + } + +} + +daemon off; diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 00000000..7c56ae57 --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,10 @@ +FROM php:fpm + +RUN apt-get update && apt-get install -y \ + libmcrypt-dev libicu-dev libpq-dev libxml2-dev \ + && docker-php-ext-install \ + iconv mcrypt mbstring intl pdo pdo_mysql pdo_pgsql + +RUN usermod -u 1000 www-data + +CMD ["php-fpm"] -- 2.41.0