Magento Commerce Cloud setup
Alternatively to Magento Commerce Cloud consider using ReadyMage. ReadyMage is ScandiPWA optimized cloud hosting and supports Magento Commerce projects.
ScandiPWA setup on Magento Commerce Cloud requires adjusting 2 files in the project root folder that are used for deployment flow.

bitbucket-pipelines.yaml

Requires adjustments to allow pushing code from BitBucket of the git repository to Magento Cloud project repository. CI/CD is used for this purpose. Git authentication is made using public keys. Generate the key in the BitBucket repository and add it to the Magento Cloud in the admin panel.
Here is an example of how the bitbucket-pipelines.yaml file should be configured. It contains configuration for 2 environments:
  • production (using master branch);
  • stage (using stage branch).
Replace example credentials and git links with your project actual links.
1
pipelines:
2
branches:
3
master:
4
- step:
5
image: luzhzh/git-client
6
script:
7
- set -e
8
- set -o pipefail
9
- git clone --branch master [email protected]:exampleorganization/exampleproject.git exampleproject
10
- cd exampleproject/
11
- git config --global user.email "[email protected]"
12
- git config --global user.name "Deploy Script"
13
- git remote add mc [email protected]:example.git
14
- git pull --no-edit mc master
15
- git push mc master
16
- cd ../
17
- rm -rf exampleproject.git/
18
stage:
19
- step:
20
image: luzhzh/git-client
21
script:
22
- set -e
23
- set -o pipefail
24
- git clone --branch stage [email protected]:exampleorganization/exampleproject.git exampleproject
25
- cd exampleproject/
26
- git config --global user.email "[email protected]"
27
- git config --global user.name "Deploy Script"
28
- git remote add mc [email protected]:example.git
29
- git pull --no-edit mc stage
30
- git push mc stage
31
- cd ../
32
- rm -rf exampleproject.git/
33
definitions:
34
caches:
35
node-custom: app/design/frontend/ExampleProject/pwa/node_modules
Copied!

magento.app.yaml

ScandiPWA compilation is done in magento.app.yaml file. Within it options and commands are configured to be run during deployment.
Here is part of the file that is responsible for ScandiPWA compilation which has to be added to the existing magento.app.yaml file content.
1
hooks:
2
# We run build hooks before your application has been packaged.
3
build: |
4
set -e
5
6
git apply m2-patches/*.patch
7
8
unset NPM_CONFIG_PREFIX
9
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | dash
10
export NVM_DIR="$HOME/.nvm"
11
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
12
nvm current
13
nvm install 12.16.1
14
15
(cd ./app/design/frontend/ExampleProject/pwa/ && rm -rf node_modules && npm ci)
16
(cd ./app/design/frontend/ExampleProject/pwa/ && npm run build)
17
18
php ./vendor/bin/ece-tools run scenario/build/generate.xml
19
php ./vendor/bin/ece-tools run scenario/build/transfer.xml
20
# We run deploy hook after your application has been deployed and started.
21
deploy: |
22
php ./vendor/bin/ece-tools run scenario/deploy.xml
23
# We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10.
24
post_deploy: |
25
php ./vendor/bin/ece-tools run scenario/post-deploy.xml
Copied!