Linux Docker setup

Follow me setting the theme up

ScandiPWA local setup on Linux

Before you start

  1. If you plan to make changes to the theme make sure to create GitHub account, or sign in into existing one.

    1. Make sure you have a SSH key assigned to your GitHub account, and you current machine has the same key. Read how to setup SSH key on GitHub.

  2. Make sure you have git and docker-compose binaries installed. To test, execute following command in the bash terminal:

  • If git was not found, please follow this installation instruction.

  • If docker-compose was not found, please follow this installation instruction.

  • Choose an installation directory. It can be anywhere on your computer. Folder /var/www/public is not necessary, prefer ~/Projects/ for ease of use.

  • Make sure the virtual memory max map count on your host machine is set high-enough. Follow the instruction to set it to appropriate level.

  • To make your life easier, make sure to create an aliases for docker-compose commands. Follow the guide to create permanent aliases. We recommend defining following:

Those aliases are required to have all services available at all times. Otherwise, if just using docker-compose only services defined in docker-composer.yml will be available.

  1. Make sure you have a valid Magento 2 COMPOSER_AUTH set. This is an environment variable set on your host machine. To test if it is set, use:

If the output of this command is empty, or, if the output (JSON object) does not contain "repo.magento.com" key, you need to set / update the environment variable.

  1. Make sure you have a valid Magento account. You can create or login to existing one on Magento Marketplace site.

  2. Upon logging to your Magento Marketplace account follow the official guide to locate and generate credentials.

  3. Now, using the following template, set the environment variable:

To set the environment variables follow this guide. Make sure to make them persist (stay between reloads).

  1. Execute following command to add scandipwa.local to your /etc/hosts file and map it to the 127.0.0.1:

When you are ready

  1. Get the copy of magento-docker - clone your fork, or clone the original repository. Do not try to download the release ZIP - it will contain outdated code.

If any other output has been returned, execute the following command to checkout the correct branch:

2. Generate and trust a self-signed SSL certificate.

  1. Begin with generating a certificate. Use the following command for that:

2. Add certificate to the list of trusted ones. Use this guide (or guide for Arch linux) to do it. The new-root-certificate.crt / foo.crt from these guide examples must be replaced with <PATH TO PROJECT ROOT>/opt/cert/scandipwa-ca.pem.

3. Reload the Google Chrome. Sometimes, the Google Chrome caches the old-certificates. Make to completely exit chrome, before opening it back. Sometimes, the “invalid certificate” issues only disappears after the full host machine reload.

4. Pull all necessary container images

There are two ways to use the setup: with frontend container and without it. The setup with frontend container is called development. The alias running it is dcf. The alias for production-like run is dc. If this is your first time setting up, run the (production-like) setup first (follow the step 4), otherwise the frontend container will not function properly.

4. Start the infrastructure in production-like mode

5. Wait until the infrastructure starts

After the previous command is executed, the site won’t be available quickly, it takes about 140s to start, you can see when the application is ready to receive the requests by watching app logs, using this command:

If you can see following output, the application is ready!Copy

6. Start the development-setup (optional)

7. Wait until the development infrastructure starts

In development setup - the page will be available much faster rather than in production-like setup - right after the theme compilation in frontend container. You can track the progress using following command:

If you can see following output, the frontend is ready!

How to access the site?

  1. To run any Magento-related command (composer, bin/magento) use inapp bash command on your host machine. Do not attempt to run them on your host machine.

  2. Open your favorite browser, i.e. Google Chrome

  3. Regardless of production or development setup go to https://scandipwa.local

    1. In production the Magento (app container) is fully responsible for what you see in browser

    2. In development the webpack-dev-server (frontend container) is responsible for frontend, while /media, /graphql, /admin URLs are still coming from Magento.

  4. To access the Maildev, go to http://scandipwa.local:1080/maildev

  5. To access the Kibana, go to http://scandipwa.local:5601

Sample-data? Yes, please!

The module scandipwa/sample-data includes following:

  • Small amount of products

  • 2 Categories

  • 3 CMS blocks

  • 3 CMS Pages

  • 1 Slider

  • 1 Menu

  • Execute into the app component:

2. Require ScandiPWA sample-data:

3. Run sample-data migration scripts:

4. Flush configuration caches updated by migration:

Want some development guidance?

Stuck? Don’t know where to start? Checkout our development guide! It will guide you through the best-practices working with ScandiPWA! How to debug, configure the code-editor, code-style checker and create your first base-template! This, and much-much more in:

Our awesome development guide

Something does not work?

Follow this simple algorithm:

  1. Refer to the FAQ page. It most probably already has the solution to your problem.

  2. If the issue still persists, join our community slack, and feel free to ask questions in #pwa_tech public channel.

  3. Alternatively create an issue on GitHub - however, the response time there will be a little-bit longer than in community Slack.

Last updated