Home

Awesome

Skywire Docker

Skywire uses docker to provide a consistent development environment across the team. This enviroment attempts to be as close a match as possible to the production environment. By doing this, we should reduce the likelyhood of issues arrising becuase of environmental factors.

1. Install Docker

2. Install Skywire Docker Configuration Into Your Project

Download the release package for your system from the releases page. Decompress the tar.gz file and then open a terminal in the new folder.

Now run the bin/install command (has to be from the root folder)

You'll be prompted for project configuration options during the installation e.g. PHP version, M1 vs. M2

Once complete a number of new files will exist in your project which define it's Docker container configuration.

3. Build and Start Docker Container

make docker-build
docker-compose up -d
127.0.0.1 docker.XXX.YYY XXX_mysql XXX_redis XXX_elasticsearch
::1 docker.XXX.YYY XXX_mysql XXX_redis XXX_elasticsearch
127.0.0.1 docker.somehost.co.uk somehost_mysql somehost_redis somehost_elasticsearch
::1 docker.somehost.co.uk somehost_mysql somehost_redis somehost_elasticsearch

At this point you should have a set of running docker containers, correctly configured for your project. We still need to configure the application of your project for Docker, which is covered below.

4. Stopping Services

This can either be done from within the Kitematic interface or by running docker-compose stop from within the project's directory.

5. Connecting to PHP container

The PHP container has all the tools required to build and use the site locally. It contains:

To connect to it you can add the following alias to your ~/.bashrc file:

de(){
    docker exec -i -t $1 bash
}

dephp() {
    de $(docker ps | grep phpfpm | cut -c1-12);
}

Once done, you can then run dephp from with in the root directory of the project to open a terminal in the PHP container.

MySQL and n98-magerun

Connection details to connect to the Docker database:

<host><![CDATA[somehost_mysql]]></host><!-- the "container_name" of the mysql container from the docker-compose.yml -->
<username><![CDATA[root]]></username><!-- Default root Username -->
<password><![CDATA[pa55w0rd]]></password><!-- Default root Password -->
<dbname><![CDATA[docker]]></dbname><!-- Default DB name -->

Varnish

Varnish is the recommended FPC for M2 and can be installed with the skywire-docker installer. Once installed via docker, you can configure it by:

Redis

ElasticSearch

ElasticHQ

Mailhog

XDebug

Add this chrome extension to allow you to turn on and off debugging and profiling

Profiling

https://www.jetbrains.com/help/phpstorm/profiling-with-xdebug.html#analyze-xdebug-profiling-data

Debugging

https://www.jetbrains.com/help/phpstorm/debugging-with-phpstorm-ultimate-guide.html

These instructions are only necessary for php 7.1 and 7.2

Mac

To get XDebug running on mac.

From:

xdebug.remote_connect_back = 1
xdebug.remote_host = 192.168.99.1
;xdebug.remote_connect_back = 0
;xdebug.remote_host = 10.254.254.254

To:

;xdebug.remote_connect_back = 1
;xdebug.remote_host = 192.168.99.1
xdebug.remote_connect_back = 0
xdebug.remote_host = 10.254.254.254

Windows

On Windows Docker will create a network interface with an IP, this is what you need to set your xdebug.remote_host to in PHP-FPM skywire_updates.ini file

The default IP should 10.0.75.1, you can check this from the docker for windows settings (found in your system tray)

You may also need to allow port 9000 through on the windows firewall, this is an exercise left to the reader.

Troubleshooting

Issue

404's and Cannot create a symlink for ... with Windows and Magento 2

Solution

In app/etc/di.xml change:

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>

to

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>

Do not commit the change.

Issue:

(Exception): Warning: SessionHandler::read()

Solution:

create var/session
chmod -R 777 var

Issue:

Magento\Framework\Exception\LocalizedException): The configuration file has changed. Run app:config:import or setup:upgrade command to synchronize configuration.

Solution:

From container

php bin/magento setup:upgrade

Issue:

mysql container shutting down after starting with error: 2018-10-29 16:54:54 7f8698032740 InnoDB: Operating system error number 13 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory.

Solution:

skywire-docker/data doesn't have correct permissions, run: chmod -R 777 skywire-docker/data

Issue:

RuntimeException: Can't create directory /var/www/html/generated/code/Magento/Framework/App/Http/. Class Magento\Framework\App\Http\Interceptor generation error: The requested class did not generate properly, because the 'generated' directory permission is read-only

Solution:

chmod -R 777 generated

Issue:

No alive nodes found in your cluster

Solution:

Check the core_config_data table in your local database, more specifically the smile_elasticsuite_core_base_settings/es_client/servers config path. That should be pointing to somehost_elasticsearch:9200 and not localhost. Check that the somehost_elasticsearch container is running, it might have errored on startup because of insufficient rights to write to skywire-docker/data/elasticsearch/data - change permissions using chmod 777 skywire-docker/data/elasticsearch/data

If the issue persists, flush the caches via php bin/magento cache:flush and reindex via php bin/magento index:reindex

Issue:

catalog_product index does not exist yet. Make sure everything is reindexed

Solution:

If you keep getting catalog_product index does not exist yet. Make sure everything is reindexed. with Smile_ElasticSearch then check if catalogsearch_fulltext indexer has stalled. If so, run php bin/magento indexer:reset catalogsearch_fulltext && php -d memory_limit=2G bin/magento indexer:reindex catalogsearch_fulltext

Issue:

Catalog Search indexer process unknown error

Solution:

Catalog Search indexer process unknown error: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [text] declared on field [search]"}],"type":"mapper_parsing_exception","reason":"No handler for type [text] declared on field [search]"},"status":400}

You are using an older version of either one of the elastic modules or the docker container.