From 5f0db96fc41122beca8c755858636c3ba2b4f7b8 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 10 May 2019 18:40:07 -0500 Subject: [PATCH] Working docker-compose files for development --- .travis/deploy_script.sh | 2 ++ Makefile | 2 +- Procfile | 4 ++-- docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ docker/nginx/default.conf | 27 +++++++++++++++++++++++++++ docker/php/Dockerfile | 3 +++ docker/php/www.conf | 12 ++++++++++++ index.php | 2 +- 8 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker/nginx/default.conf create mode 100644 docker/php/Dockerfile create mode 100644 docker/php/www.conf diff --git a/.travis/deploy_script.sh b/.travis/deploy_script.sh index 8da3714f..d9441b09 100755 --- a/.travis/deploy_script.sh +++ b/.travis/deploy_script.sh @@ -55,6 +55,7 @@ if [ "$TRAVIS" = "true" ]; then .sass-cache .idea .travis + docker tests _ide_helper.php .dpl @@ -64,6 +65,7 @@ if [ "$TRAVIS" = "true" ]; then .styleci.yml env.php config.php + docker-compose.yml Makefile phpunit.xml phpvms.iml diff --git a/Makefile b/Makefile index 9f46b63d..f8fdd70e 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ update: build @echo "Done!" .PHONY: reset -reset: cleanapp/Models/Traits/JournalTrait.php +reset: clean @php $(COMPOSER) dump-autoload @make reload-db diff --git a/Procfile b/Procfile index e37f7486..340b8c19 100644 --- a/Procfile +++ b/Procfile @@ -1,5 +1,5 @@ -dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground +#dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground php-fpm: /usr/local/sbin/php-fpm --nodaemonize nginx: /usr/local/bin/nginx -g 'daemon off;' -#mysql: /usr/local/bin/mysqld +mysql: docker-compose --file ~/docker/mysql/docker-compose.yml up #mailhog: /usr/local/bin/mailhog diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..84f7b788 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +--- +version: '3' + +services: + app: + build: + context: ./docker/php + environment: + DB_HOST: mysql + volumes: + - ./:/var/www + - ./docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf + depends_on: + - mysql + + nginx: + image: nginx:1.13.8 + command: /bin/bash -c "exec nginx -g 'daemon off;'" + volumes: + - ./:/var/www + - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf + ports: + - 80:80 + depends_on: + - app + + mysql: + image: mysql:5.7.26 + environment: + - MYSQL_DATABASE=phpvms + - MYSQL_ROOT_PASSWORD= + - MYSQL_ALLOW_EMPTY_PASSWORD=yes + volumes: + - mysql-data:/var/lib/mysql + ports: + - 3306 + +volumes: + mysql-data: diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf new file mode 100644 index 00000000..ced8c907 --- /dev/null +++ b/docker/nginx/default.conf @@ -0,0 +1,27 @@ +server { + listen 80 default_server; + server_name phpvms.test; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + root /var/www/public; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass app:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include /etc/nginx/fastcgi_params; + } + + location ~ /\.ht { + deny all; + } +} diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile new file mode 100644 index 00000000..791d094a --- /dev/null +++ b/docker/php/Dockerfile @@ -0,0 +1,3 @@ +FROM php:7.3-fpm + +RUN docker-php-ext-install mysqli pdo openssl mbstring tokenizer curl json gmp diff --git a/docker/php/www.conf b/docker/php/www.conf new file mode 100644 index 00000000..57a5e5dd --- /dev/null +++ b/docker/php/www.conf @@ -0,0 +1,12 @@ +[www] + +user = www-data +group = www-data + +listen = :9000 + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 diff --git a/index.php b/index.php index 3e89c0a5..8886dbb6 100755 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@