This guide is for setting up on linux machines. This guide is meant for local installation only.
?> Note: video is coming soon!
-
If you plan to make changes to the theme make sure to create GitHub account, or sign in into existing one.
-
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.
-
Make sure to fork
scandipwa-baserepository. Read how to fork repository on GitHub.
-
-
Make sure you have
gitanddocker-composebinaries installed. To test, execute following command in the bash terminal:git --version # it should be ^2 docker-compose -v # it should be ^1.24
-
If
gitwas not found, please follow this installation instruction. -
If
docker-composewas not found, please follow this installation instruction.
-
-
Choose an installation directory. It can be anywhere on your computer. Folder
/var/www/publicis not necessary, prefer~/Projects/for ease of use. -
Make sure the virtual memory
max map counton 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:
# use `dc` to start without `frontend` container alias dc="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml" # use `dcf` to start with `frontend` container alias dcf="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml" # use `inapp` to quickly get inside of the app container alias inapp="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml exec -u user app" # use `applogs` to quickly see the last 100 lines of app container logs alias applogs="docker-compose logs -f --tail=100 app" # use `frontlogs` to quickly see the last 100 lines of frontend container logs alias frontlogs="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml logs -f --tail=100 frontend"
Those aliases are required to have all services available at all times. Otherwise, if just using
docker-composeonly services defined indocker-composer.ymlwill be available. Understand what services are available at all by reading this part of our documentation. -
Make sure you have a valid Magento 2
COMPOSER_AUTHset. This is an environment variable set on your host machine. To test if it is set, use:env | grep COMPOSER_AUTHIf 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.-
Make sure you have a valid Magento account. You can create or login to existing one on Magento Marketplace site.
-
Upon logging to your Magento Marketplace account follow the official guide to locate and generate credentials.
-
Now, using the following template, set the environment variable:
export COMPOSER_AUTH='{"http-basic":{"repo.magento.com": {"username": "<PUBLIC KEY FROM MAGENTO MARKETPLACE>", "password": "<PRIVATE KEY FROM MAGENTO MARKETPLACE>"}}}'
To set the environment variables follow this guide. Make sure to make them persist (stay between reloads).
-
-
Execute following command to add
scandipwa.localto your/etc/hostsfile and map it to the127.0.0.1:echo '127.0.0.1 scandipwa.local' | sudo tee -a /etc/hosts
-
Get the copy of
scandipwa-base- clone your fork, or clone the original repository. Do not try to download the release ZIP - it will contain outdated code.# to clone the fork git clone git@github.com:<YOUR GITHUB USERNAME>/scandipwa-base.git # to clone the original repository git clone git@github.com:scandipwa/scandipwa-base.git # to clone via HTTPS (not recommended) git clone https://github.com/scandipwa/scandipwa-base.git
Note: sometimes, after the repository is cloned, the git chooses the
masterbranch as default. This is the legacy (incorrect) default branch in case ofscandipwa-base. Please make sure you are using2.x-stable. You can do it using following command:git status # expected output `On branch 2.x-stable`If any other output has been returned, execute the following command to checkout the correct branch:
git checkout 2.x-stable
-
Generate and trust a self-signed SSL certificate.
-
Begin with generating a certificate. Use the following command for that:
make cert
Note: you will be asked to type in the password 6 times. This is NOT your host machine password, this is a NEW password for your certificate. This password must be at least 6 characters long.
-
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.crtfrom these guide examples must be replaced with<PATH TO PROJECT ROOT>/opt/cert/scandipwa-ca.pem. -
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.
-
-
Pull all necessary container images
Note:
container image!=media image. Read more about container images here.# if you have the alias set up dcf pull # without aliases (not recommended) docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml pull
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.
?> Note: If you have already ran ScandiPWA in production-like mode once, you can safely skip to step 6. In case, of course, you plan on development.
-
Start the infrastructure in production-like mode
# if you have the alias set up dc up -d --remove-orphans # without aliases (not recommended) docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml up -d --remove-orphans
Note: the
--remove-orphansflag is necessary to remove all left-over containers. In example, if you switched from development to production setup, thefrontendcontainer won't keep running. -
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
applogs, using this command:# if you have the alias set up applogs # without aliases (not recommended) docker-compose logs -f --tail=100 app
If you can see following output, the application is ready!
NOTICE: ready to handle connections
-
Start the development-setup (optional)
# if you have the alias set up dcf up -d --remove-orphans # without aliases (not recommended) docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml up -d --remove-orphans
-
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
frontendcontainer. You can track the progress using following command:# if you have the alias set up frontlogs # without aliases (not recommended) docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml logs -f --tail=100 frontend
If you can see following output, the frontend is ready!
ℹ 「wdm」: Compiled successfully
Note: the requests to
/graphqlwill still fail, you need to wait until theappcontainer starts. See instruction in step 5 to see how.
-
Open your favorite browser, i.e. Google Chrome
-
Regardless of production or development setup go to https://scandipwa.local
-
In production the Magento (
appcontainer) is fully responsible for what you see in browser -
In development the webpack-dev-server (
frontendcontainer) is responsible for frontend, while/media,/graphql,/adminURLs are still coming from Magento.
-
-
To access the Maildev, go to http://scandipwa.local:1080/maildev
-
To access the Kibana, go to http://scandipwa.local:5601
To get the demo.scandipwa.com content (but without multi-store and languages) follow this step-by-step guide:
-
Stop the
appcontainer, using following command:# if you have the alias set up dc stop app # without aliases (not recommended) docker-compose stop app
-
Drop the existing database
docker-compose exec mysql mysql -u root -pscandipwa -e "DROP DATABASE magento; CREATE DATABASE magento;"
-
Import the demo site database dump
docker-compose exec -T mysql mysql -u root -pscandipwa magento < deploy/latest.sql
-
Recreate the infrastructure
docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml up -d --force-recreate
-
Get the media files
There are two options to get the media files - automatic (using wget), and manual.
-
Get media files automatically
Note: the following command requires you to have the
wgetbinary available. To check if it is available, use following command:wget --version # should output version ^1If the
wgetcommand is not found, follow this guide to get it. Else, or after installation, execute following command to download & extract media:wget -c https://scandipwa-public-assets.s3-eu-west-1.amazonaws.com/2.2.x-media.tar.gz -O - | sudo tar -xz -C <PATH TO PROJECT ROOT>src/pub/media
-
Get media files manually
-
Download media files from S3 bucket
-
Move archive into the
<PATH TO PROJECT ROOT>src/pub/mediafolder -
Extract the archive using following command:
tar -zxvf scandipwa_media.tgz
-
-
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:
Follow this simple algorithm:
-
Refer to the FAQ page. It most probably already has the solution to your problem.
-
If the issue still persists, join our community slack, and feel free to ask questions in
#pwa_techpublic channel. -
Alternatively create an issue on GitHub - however, the response time there will be a little-bit longer than in community Slack.