-
-
Notifications
You must be signed in to change notification settings - Fork 0
Docker Local Environment Advanced Configuration

| Variable | Containers | Default Value | Description |
|---|---|---|---|
| TZ | php-cli php-fpm nginx |
America/New_York | PHP timezone |
| UPLOAD_MAX_FILESIZE | php-cli php-fpm nginx |
64M | The maximum size of an uploaded file for PHP. Sets value for client_max_body_size setting for Nginx |
| MAGENTO_RUN_MODE | php-cli php-fpm nginx |
developer | Magento Run Mode |
| PHP_MEMORY_LIMIT | php-fpm | 4G | Sets the maximum amount of memory in bytes that a script is allowed to allocate Magento recommendations are: Compiling code or deploying static assets: 1G Debugging: 2G Testing: ~3-4G |
| PHP_ENABLE_XDEBUG | php-cli php-fpm |
false | Enable XDebug for the Magento 2. |
| DEBUG | php-cli php-fpm nginx |
false | Debug docker container |
| COMPOSER_GITHUB_TOKEN | php-cli | null | GitHub Composer Token. Create A Token |
| COMPOSER_MAGENTO_USERNAME | php-cli | null | Magento 2 Composer MAGEID |
| COMPOSER_MAGENTO_PASSWORD | php-cli | null | Magento 2 Composer TOKEN |
| PHP_IDE_CONFIG | php-cli php-fpm |
serverName=magento | XDebug server name for PHPStorm configuration |
| MAGENTO_ROOT | php-cli php-fpm nginx |
/var/www/magento | Magento directory inside a container. |
| FPM_HOST | nginx | fpm | Name of the php-fpm for fastcgi_backend. Its rewritten per project in the docker-compose.yml |
| FPM_PORT | nginx | 9000 | The php-fpm port for fastcgi_backend |
| NGINX_WORKER_PROCESSES | nginx | 1 | Defines the number of worker processes. |
| NGINX_WORKER_CONNECTIONS | nginx | 1024 | Sets the maximum number of simultaneous connections that can be opened by a worker process. |
| UPSTREAM_HOST | nginx | web | The php-fpm host for Nginx proxy_pass |
| UPSTREAM_PORT | nginx | 8080 | The php-fpm port for Nginx proxy_pass |
| COMPOSER_ALLOW_SUPERUSER | php-cli | 1 | COMPOSER_ALLOW_SUPERUSER |
| COMPOSER_HOME | php-cli | /var/www/composer | COMPOSER_HOME |
| NODE_VERSION | php-cli | --lts | Node version for NVM |
When you want to use a different version of PHP, Elasticsearch, Redis or other service you may change it at the image node:
image: 'sashas777/magento-php:7.4-fpm'
There is a List of Available Images
Add a request for a new image at the Github Issue Tracker.
All PHP containers have Sendmail connected to the MailHog served by Local Services.
You may rewrite it at a container level. Create a file at ./dev/phpmail.ini with custom configuration then modify the docker-compose.yml file by adding the following line to the volumes section of the fpm service. The modified volumes section would look like this:
volumes:
- ./src:/var/www/magento:rw
- ./dev/php-mail.ini:/usr/local/etc/php/conf.d/zz-mail.ini
There are 2 options to configure a multi-store website:
- You can leverage the
magento-vars.phpDocumentation (Modify Variables Chapter). The system has a default version of the file but you can replace it by yours. In the case when your file is insrc/magento-vars.phpyou will need to modifydocker-compose.ymlfollowing way:
fpm:
image: 'sashas777/magento-php:8.1-fpm'
....
volumes:
- ./src:/var/www/magento:rw
- ./src/magento-vars.php:/var/www//magento-vars.php:ro -- New Line
....
- By default, Nginx is configured for one website. (Configuration) If you wish to modify it you can rewrite it at the dock-compose.yml file by adding the following line to the volumes section of the web service.
/mapping.conf file with the configuration you need and then modify the docker-compose.yml file by adding the following line for web service:
- ./dev/mapping.conf:/etc/nginx/conf.d/a-mapping.conf
web:
image: 'sashas777/magento-nginx:latest'
....
volumes:
- ./src:/var/www/magento:rw
- ./dev/mapping.conf:/etc/nginx/conf.d/a-mapping.conf
...
| Variable | Description |
|---|---|
| MAGENTO_ROOT | Magento working directory inside the docker container. Default: /var/www/magento
|
| Variable | Description |
|---|---|
| FPM_HOST | Docker host for PHP-FPM Service. Default: fpm
|
| FPM_PORT | Port. Default: 9000
|
| NGINX_WORKER_PROCESSES |
Defines the number of worker processes. Default: 1
|
| NGINX_WORKER_CONNECTIONS |
Sets the maximum number of simultaneous connections that can be opened by a worker process. Default: 1024
|
| UPSTREAM_HOST | A host were Nginx will listen for incoming connections. Default: web
|
| UPSTREAM_PORT | A port were Nginx will listen for incoming connections. Default: 8080
|
| MAGENTO_ROOT | Magento working directory inside a docker container. Default: /var/www/magento
|
- Copy a new VCL File to your project directory's dev folder. (Example:
default.vcl) - Edit docker-compose.yml file: Add volume with a path to default.vcl to the varnish container:
varnish:
image: 'sashas777/magento-varnish:7.0'
container_name: ${PROJECT_NAME}-varnish
hostname: varnish.${WEBSITE_DOMAIN}
restart: unless-stopped
volumes:
- ./dev/default.vcl:/etc/varnish/default.vcl --- New Line
labels:
- traefik.enable=true
- traefik.http.routers.${PROJECT_NAME}-varnish.tls=true
- traefik.http.routers.${PROJECT_NAME}-varnish.priority=1
- traefik.http.routers.${PROJECT_NAME}-varnish.rule=Host(`varnish.${WEBSITE_DOMAIN}`)
- traefik.http.services.${PROJECT_NAME}-varnish.loadbalancer.server.port=80
- Restart containers:
docker-compose stop
docker-compose up -d
When you decide to use Xdebug for your project follow these steps:
- Copy php-xdebug.ini file to your project directory's dev folder.
- Edit docker-compose.yml file: Add volume with php-xdebug.ini to the fpm container:
fpm:
image: 'sashas777/magento-php:7.4-fpm'
container_name: ${PROJECT_NAME}-fpm
hostname: fpm.magento2.docker
ports:
- 9000
env_file:
- ./global.env
restart: unless-stopped
volumes:
- ./src:/var/www/magento:rw
- ./dev/php-xdebug.ini:/usr/local/etc/php/conf.d/zz-xdebugsettings.ini -- New Line
- Restart containers:
docker-compose stop
docker-compose up -d
You may want to use a custom Magento 2 Nginx configuration. (Built-in Config) For this you will need to mount a new volume to the web container. For example, you want to use a new nginx.conf.sample:
- Copy it to the project's dev directory
- Edit docker-compose.yml file: Add volume with nginx.conf.sample to the web container:
web:
image: 'sashas777/magento-nginx:latest'
container_name: ${PROJECT_NAME}-web
depends_on:
- fpm
env_file:
- ./global.env
restart: unless-stopped
volumes:
- ./src:/var/www/magento:rw
- ./dev/nginx.conf.sample:/etc/nginx/magento.conf.sample -- New Line
labels:
- traefik.enable=true
- traefik.http.routers.${PROJECT_NAME}-web.tls=true
- traefik.http.routers.${PROJECT_NAME}-web.rule=Host(`${WEBSITE_DOMAIN}`)
- traefik.http.services.${PROJECT_NAME}-web.loadbalancer.server.port=8080
- Restart containers:
docker-compose stop
docker-compose up -d