Skip to content

Commit

Permalink
Merge pull request #20 from ityetti/develop
Browse files Browse the repository at this point in the history
Fixed to avoid the proxying cycle between varnish and nginx.
  • Loading branch information
ityetti authored Nov 30, 2024
2 parents 5ccc15e + 19b2dcc commit 7378752
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 151 deletions.
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,84 @@ Install project (don't forget to change **--base-url** to yours):
## Setting up Magento
To access the magento homepage, go to the following url: https://magento2.test<br>

<details>

<summary>Storing sessions and cache in redis.</summary>

##### As reference, you could use `env.php.magento.sample`

#### Setting up the configuration for sessions.

```php
'session' => [
'save' => 'redis',
'redis' => [
'host' => 'redis',
'port' => '6379',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'database' => '2',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
]
]
```

#### Setting up the configuration for cache.

```php
'cache' => [
'frontend' => [
'default' => [
'id_prefix' => '777_',
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => 'redis',
'database' => '0',
'port' => '6379',
'compress_data' => '1',
'compress_tags' => '1'
]
],
'page_cache' => [
'id_prefix' => '777_',
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => 'redis',
'port' => '6379',
'database' => '1',
'compress_data' => '0'
]
]
],
'allow_parallel_generation' => false
],
```

#### Don't forget to add `http_cache_hosts` to correct the varnish purge.

```php
'http_cache_hosts' => [
[
'host' => 'nginx',
'port' => '8080'
]
]
```

</details>

## How to use xDebug
You could enable or disable xDebug with the next command: `./scripts/switch_mode [fpm|xdebug]`<br>
`fpm` - Enable container without xDebug <br>
Expand All @@ -138,6 +216,7 @@ https://rabbit.magento2.test - **RabbitMQ** (guest/guest for access)<br>
- v1.0.8 - Replace mailhog to mailpit
- v1.0.9 - Add n98-magerun2
- v1.1.0 - Add a switcher for PHP that enables or disables xDebug
- v1.1.1 - Fixed to avoid the proxying cycle between varnish and nginx.

## Branches
| Name | Magento versions |
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ services:
- magento
labels:
- "traefik.enable=false"
expose:
- "8080"

php-fpm:
build: ./php-fpm
Expand Down Expand Up @@ -221,7 +223,7 @@ services:
- CACHE_SIZE=1G
expose:
- "6081"
command: ["varnishd", "-F", "-a", ":6081", "-b", "nginx:80"]
command: ["varnishd", "-F", "-a", ":6081", "-b", "nginx:8080"]

networks:
magento:
Expand Down
130 changes: 130 additions & 0 deletions env.php.magento.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
return [
'remote_storage' => [
'driver' => 'file'
],
'backend' => [
'frontName' => 'admin'
],
'cache' => [
'graphql' => [
'id_salt' => 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'
],
'frontend' => [
'default' => [
'id_prefix' => '777_',
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => 'redis',
'port' => '6379',
'database' => '0',
'compress_data' => '1',
'compress_tags' => '1'
]
],
'page_cache' => [
'id_prefix' => '777_',
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => 'redis',
'port' => '6379',
'database' => '1',
'compress_data' => '0'
]
]
],
'allow_parallel_generation' => false
],
'config' => [
'async' => 0
],
'queue' => [
'consumers_wait_for_messages' => 1
],
'crypt' => [
'key' => 'base641+a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'
],
'db' => [
'table_prefix' => '',
'connection' => [
'default' => [
'host' => 'mysql',
'dbname' => 'magento_db',
'username' => 'magento_user',
'password' => 'PASSWD#',
'model' => 'mysql4',
'engine' => 'innodb',
'initStatements' => 'SET NAMES utf8;',
'active' => '1',
'driver_options' => [
1014 => false
]
]
]
],
'resource' => [
'default_setup' => [
'connection' => 'default'
]
],
'x-frame-options' => 'SAMEORIGIN',
'MAGE_MODE' => 'developer',
'session' => [
'save' => 'redis',
'redis' => [
'host' => 'redis',
'port' => '6379',
'database' => '2',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
]
],
'lock' => [
'provider' => 'db'
],
'directories' => [
'document_root_is_pub' => true
],
'cache_types' => [
'config' => 1,
'layout' => 1,
'block_html' => 1,
'collections' => 1,
'reflection' => 1,
'db_ddl' => 1,
'compiled_config' => 1,
'eav' => 1,
'customer_notification' => 1,
'config_integration' => 1,
'config_integration_api' => 1,
'graphql_query_resolver_result' => 1,
'full_page' => 1,
'config_webservice' => 1,
'translate' => 1
],
'downloadable_domains' => [
'magento2.test'
],
'install' => [
'date' => 'Tue, 26 Nov 2024 01:33:37 +0000'
],
'http_cache_hosts' => [
[
'host' => 'nginx',
'port' => '8080'
]
]
];
1 change: 0 additions & 1 deletion nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ FROM arm64v8/nginx:1.22
RUN groupadd -g 2000 magento \
&& useradd -d /home/magento -u 2000 -g 2000 magento

COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./default.conf /etc/nginx/conf.d/default.conf
Loading

0 comments on commit 7378752

Please sign in to comment.