diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f7083c..00eaf22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.3.0] +### Added +- Extended PHP environment for generic use that is more inline with the current magento stack. + ## [1.2.0] ### Changed - M2: Redis now has its own `volume` so config cache and sessions persist between a `dev down && dev up`. diff --git a/templates/extended-php/.env.dev b/templates/extended-php/.env.dev new file mode 100644 index 0000000..cef9e42 --- /dev/null +++ b/templates/extended-php/.env.dev @@ -0,0 +1,51 @@ +################################################################################ +# Google Cloud data source configuration # +################################################################################ +GCLOUD_BUCKET_URL_DB="gs:///fixtures/db.sql" +GCLOUD_BUCKET_URL_MEDIA="gs:///fixtures/media.tgz" + +################################################################################ +# DNS configuration # +################################################################################ +DNS_NAME=".dev.mediacthq.nl" + +################################################################################ +# Remaining configuration # +################################################################################ + +# Miscellaneous configuration +CLOUDSDK_PYTHON=/usr/bin/python +GCLOUD_LOCAL="~/.config/gcloud" +PHP_VERSION="8.1" + +# XDebug v2 config (used for PHP < 8.0) +# XDEBUG_CONFIG="remote_host=${HOST_IP} coverage_enable=0 remote_enable=1 remote_connect_back=1" +# COMPOSER_ALLOW_XDEBUG=0 + +# XDebug v3 config (used for PHP >= 8.0) +XDEBUG_CONFIG="client_host=${HOST_IP}" +COMPOSER_ALLOW_XDEBUG=0 + +# Port configuration +MAILHOG_PORT=8025 +WEB_PORT_HTTP=80 +WEB_PORT_HTTPS=443 + +# Database +MYSQL_PORT=3306 +MYSQL_ROOT_PASSWORD=iu45874j9ufeiijfr0 +DB_HOST=db +DB_USER=root +DB_PASS="${MYSQL_ROOT_PASSWORD}" +DB_NAME=magento + +# PHP-FPM +PHP_FPM_HOST=php-fpm +PHP_FPM_PORT=9000 +NGINX_PHP_FPM_HOST=nginx-php-fpm +NGINX_PHP_FPM_PORT=80 + +# Redis +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_PASSWORD= diff --git a/templates/extended-php/docker-compose.yml b/templates/extended-php/docker-compose.yml new file mode 100644 index 0000000..1abb6f6 --- /dev/null +++ b/templates/extended-php/docker-compose.yml @@ -0,0 +1,124 @@ +# vim: ai:ts=2:sw=2:et +version: "3.4" +networks: + backend: +volumes: + db-data: + +x-custom: + version: 1.2.0 + type: extended-php + environment: &env-vars + # Environment settings + - COMPOSER_MEMORY_LIMIT=-1 + - "HOME=${CHOME}" + - HTTPS=on + - SSH_AUTH_SOCK + - XDEBUG_CONFIG + - COMPOSER_ALLOW_XDEBUG + # Database settings + - DB_HOST + - DB_USER + - DB_PASS + - DB_NAME + - MYSQL_PORT + # GCP settings + - CLOUDSDK_CONFIG=/config/mygcloud + - GCLOUD_BUCKET_URL_DB + - GCLOUD_BUCKET_URL_MEDIA + +services: + console: + image: "eu.gcr.io/mct-deployments/magento-2-console:php${PHP_VERSION}-composer2" + user: "${CUID}:${CGID}" + links: + - db + - mailcatch + - redis + networks: + - backend + environment: *env-vars + extra_hosts: + - "${DNS_NAME}:${HOST_IP}" + working_dir: "${PWD}" + volumes: + - "${HOME}:${CHOME}" + - "${PWD}:${PWD}" + - "${GCLOUD_LOCAL}:/config/mygcloud" + - "${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}" + - /etc/group:/etc/group:ro + - /etc/passwd:/etc/passwd:ro + - /etc/shadow:/etc/shadow:ro + + db: + image: percona:8 + command: mysqld --default-authentication-plugin=mysql_native_password + networks: + - backend + ports: + - "${MYSQL_PORT}:3306" + environment: + - MYSQL_ROOT_PASSWORD + volumes: + - db-data:/var/lib/mysql:rw + + mailcatch: + image: mailhog/mailhog + networks: + - backend + ports: + - "${MAILHOG_PORT}:8025" + + nginx-php-fpm: + image: eu.gcr.io/mct-deployments/magento-2-nginx-php-fpm + networks: + - backend + links: + - php-fpm + working_dir: "${PWD}" + environment: + - "MAGE_ROOT=${PWD}" + - PHP_FPM_HOST + - PHP_FPM_PORT + extra_hosts: + - "${DNS_NAME}:${HOST_IP}" + volumes: + - "${PWD}:${PWD}:ro" + - ./nginx-dev.conf:/etc/nginx/app.conf:ro + + nginx-ssl-proxy: + image: eu.gcr.io/mct-deployments/mediacthq-dev-nginx-ssl-proxy + networks: + - backend + links: + - nginx-php-fpm + ports: + - "${WEB_PORT_HTTP}:80" + - "${WEB_PORT_HTTPS}:443" + environment: + - PROXY_HOST + - PROXY_PORT + working_dir: "${PWD}" + + php-fpm: + image: "eu.gcr.io/mct-deployments/magento-2-php-fpm:${PHP_VERSION}" + user: "${CUID}:${CGID}" + networks: + - backend + links: + - db + - mailcatch + - redis + environment: *env-vars + working_dir: "${PWD}" + volumes: + - "${PWD}:${PWD}:rw" + - /etc/group:/etc/group:ro + - /etc/passwd:/etc/passwd:ro + - /etc/shadow:/etc/shadow:ro + + redis: + image: redis:6-alpine + command: ["redis-server", "--appendonly", "yes"] + networks: + - backend \ No newline at end of file diff --git a/templates/extended-php/nginx-dev.conf b/templates/extended-php/nginx-dev.conf new file mode 100644 index 0000000..c6125e3 --- /dev/null +++ b/templates/extended-php/nginx-dev.conf @@ -0,0 +1,83 @@ +## Example configuration: +# upstream fastcgi_backend { +# # use tcp connection +# # server 127.0.0.1:9000; +# # or socket +# server unix:/var/run/php/php7.0-fpm.sock; +# } +# server { +# listen 80; +# server_name mage.dev; +# set $MAGE_ROOT /var/www/magento2; +# set $MAGE_DEBUG_SHOW_ARGS 1; +# include /vagrant/magento2/nginx.conf.sample; +# } +# +## Optional override of deployment mode. We recommend you use the +## command 'bin/magento deploy:mode:set' to switch modes instead. +## +## set $MAGE_MODE default; # or production or developer +## +## If you set MAGE_MODE in server config, you must pass the variable into the +## PHP entry point blocks, which are indicated below. You can pass +## it in using: +## +## fastcgi_param MAGE_MODE $MAGE_MODE; +## +## In production mode, you should uncomment the 'expires' directive in the /static/ location block + +root $MAGE_ROOT/public; + +index index.php; +autoindex off; +charset UTF-8; +error_page 404 403 = /errors/404.php; +#add_header "X-UA-Compatible" "IE=Edge"; + +# Deny access to sensitive files +location /\.* { + deny all; +} + +location / { + try_files $uri $uri/ /index.php$is_args$args; +} + +# PHP entry point for main application +location ~ ^/index\.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_buffers 1024 4k; + fastcgi_buffer_size 128k; + + fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; + fastcgi_param PHP_VALUE "memory_limit=2G \n max_execution_time=18000"; + fastcgi_read_timeout 600s; + fastcgi_connect_timeout 600s; + + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; +} + +gzip on; +gzip_disable "msie6"; + +gzip_comp_level 6; +gzip_min_length 1100; +gzip_buffers 16 8k; +gzip_proxied any; +gzip_types + text/plain + text/css + text/js + text/xml + text/javascript + application/javascript + application/x-javascript + application/json + application/xml + application/xml+rss + image/svg+xml; +gzip_vary on; +