SlideShare a Scribd company logo
1 of 48
Running
in production
Tjitse Efdé | Vendic
The end result… Tadaa!
Vue Storefront runs reliable
in production!
❏ Live April 26th, 2019
❏ No crashes or outages
❏ The minor issues we had in
production were mostly in
the configuration of Vue
Storefront
The ‘new’ technology stack for Magento 2 dev
1.
2.
3.
4.
5.
6.
7.
8.
9. And many other JavaScript libraries
MVP: minimum VS instance connected to M2
STEP 2
Setup a M2
instance with
products
STEP 4
Pump the
catalog into
ElasticSearch
STEP 1
Prepare the
server
STEP 3
Setup the VS
components:
frontend & API
STEP 5
Start the VS
frontend & API
STEP 6
Start
developing
custom theme
1. Prepare the
server
We’re not using docker in
production
We will be working with Redis and ElasticSearch directly
Redis will be used as a job queue system
(Kue)
1. Prepare the server
Elastic will hold our catalog data
1. Prepare the server
1. Prepare the server
We use a reverse proxy (HAProxy) for SSL offloading and to serve the
HTTP request to the right application
The server is
configured! Let’s install
the apps.
We skip step 2 (M2 setup) and fast
forward to step 3.
3. Setup VS API
1. Clone the repo
2. Setup the local.json, which contains
the settings
3. Add your Magento API credentials
4. Run yarn to install dependencies
5. Run yarn migrate to prepare elastic
{
"server": {
"host": "localhost",
"port": 8080,
"searchEngine": "elasticsearch"
},
"orders": {
"useServerQueue": false
},
"catalog": {
"excludeDisabledProducts": false
},
"elasticsearch": {
"host": "localhost",
"port": 9200,
"protocol": "http",
"user": "elastic",
"password": "changeme",
"min_score": 0.01,
"indices": [
"vue_storefront_catalog",
"vue_storefront_catalog_de",
"vue_storefront_catalog_it"
],
"indexTypes": [
"product",
"category",
"cms",
"attribute",
"taxrule",
"review"
],
"apiVersion": "5.6"
},
"redis": {
"host": "localhost",
"port": 6379,
"db": 0
},
"kue": {}
}
3. Setup VS
frontend
1. Clone the repo
2. Setup the local.json, which contains
the settings
3. Add your VS API endpoints. If you
use the demo API, skip this step
4. Run yarn to install dependencies
{
"server": {
"host": "localhost",
"port": 3000,
"protocol": "http",
"api": "api",
"devServiceWorker": false,
"useOutputCacheTagging": false,
"useOutputCache": false,
"outputCacheDefaultTtl": 86400,
"availableCacheTags": ["product", "category", "home",
"checkout", "page-not-found", "compare", "my-account", "P",
"C", "error"],
"invalidateCacheKey": "aeSu7aip",
"dynamicConfigReload": false,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["ssr", "storeViews",
"entities", "localForage", "shipping", "boost", "query"],
"dynamicConfigInclude": [],
"elasticCacheQuota": 4096
},
"seo": {
"useUrlDispatcher": true
}
}
Mage2VueStorefront
OR
VueStorefront Indexer
for Magento 2
4. Import data from Magento 2 to VS
Mage2VueStorefront
❏ A seperate Node app on the server
❏ Full reindexes of the Magento 2
catalog, pages and cms blocks
❏ Uses a products delta index that
runs as a cron job to update
changed data in Vue Storefront
❏ First release 2nd of june 2018
VueStorefront indexer
❏ Magento 2 extension installed via
composer
❏ Adds Vue Storefront indexers to
Magento 2
❏ Runs with the Magento 2 default cron
group
❏ First release on the 2nd of april 2019
4. Import data from Magento 2 to VS
OR
1. Clone the mage2vs repo
2. Variables inserted via
process.env global variables
3. Create a shell script to set the
variables
4. Run the initial import
5. Setup the products delta
indexer with a cron job
#!/usr/bin/env bash
export TIME_TO_EXIT=2000
export MAGENTO_CONSUMER_KEY=byv3730rhoulpopcq64don8ukb8lf2gq
export MAGENTO_CONSUMER_SECRET=u9q4fcobv7vfx9td80oupa6uhexc27rb
export MAGENTO_ACCESS_TOKEN=040xx3qy7s0j28o3q0exrfop579cy20m
export MAGENTO_ACCESS_TOKEN_SECRET=7qunl3p505rubmr7u1ijt7odyialnih9
echo 'Default store - in our case United States / en'
export MAGENTO_URL=http://demo-magento2.vuestorefront.io/rest
export INDEX_NAME=vue_storefront_catalog
node --harmony cli.js categories --removeNonExistent=true
node --harmony cli.js productcategories --partitions=1
node --harmony cli.js attributes --removeNonExistent=true
node --harmony cli.js taxrule --removeNonExistent=true
node --harmony cli.js products --removeNonExistent=true --partitions=1
node --harmony cli.js reviews
4. Import data from Magento 2 to VS
✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server
✅ Setup Vue Storefront frontend & API
✅ Setup Magento 2 and added a new API user
✅ Indexer chosen and imported data to Elastic
❌ Ran the Node applications and kept them running
❌ Developed a custom theme
Running
applications in a
production
environment
{
"apps": [
{
"name": "frontend",
"max_memory_restart": "4G",
"instances": "4",
"exec_mode": "cluster",
"script": "./core/scripts/server.js",
"node_args": "--
max_old_space_size=1024",
"log_date_format": "YYYY-MM-DD
HH:mm:ss",
"ignore_watch": [
"core/build/config.json",
"node_modules"
]
}
]
Command line tool for easy environment management with
configuration files. Example ecosystem.json:
PM2 Node Process Manager
Nice overview of deployed apps with pm2 status
PM2 Node Process Manager
Other features include:
❏ Zero downtime
deployments
❏ Application logging
(logrotate)
❏ Application monitoring
(memory and CPU)
❏ Up and down schaling of
cluster processes
PM2 Node Process Manager
✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server
✅ Setup Vue Storefront frontend & API
✅ Setup Magento 2 and added a new API user
✅ Indexer chosen and imported data to Elastic
✅ Ran the Node applications and kept them running
❌ Developed a custom theme
Headless theme development
A unified
configuration
across multiple
environments
{
"server": {
"host": "86.109.18.208",
"port": 3333,
"protocol": "http",
"api": "api"
}
{
"server": {
"host": "localhost",
"port": 3000,
"protocol": "http",
"api": "api"
}
Vue Storefront has hundreds of settings,
it’s easy to overlook something.
A unified configuration across multiple environments
Vue Storefront uses https://github.com/lorenwest/node-config
behind the scenes.
A unified configuration across multiple environments
{
"server": {
"host": "86.109.18.208",
"port": 3000,
"protocol": "http",
"api": "api",
"devServiceWorker": false,
"useOutputCacheTagging": false,
"useOutputCache": false,
"outputCacheDefaultTtl": 86400,
"availableCacheTags": ["product", "category", "home", "checkout", "page-
not-found", "compare", "my-account", "P", "C", "error"],
"invalidateCacheKey": "aeSu7aip",
"dynamicConfigReload": false,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage",
"shipping", "boost", "query"],
"dynamicConfigInclude": [],
"elasticCacheQuota": 4096
},
"seo": {
"useUrlDispatcher": false
},
"console": {
"showErrorOnProduction" : true,
"verbosityLevel": "display-everything"
},
"redis": {
"host": "86.109.18.208",
"port": 6381,
"db": 0
},
"graphql":{
"host": "localhost",
"port": 8080
},
"elasticsearch": {
"httpAuth": "",
"host": "https://www.meubelplaats.nl/api/catalog",
"index": "vue_storefront_catalog",
"min_score": 0.02
}
Our local.json contains:
❏ Environment specific
data like IP addresses,
ports and specific
endpoints.
❏ Global settings
(for example stock
settings)
Cool feature:
custom-environment-variables.json
{
"server": {
"host": "86.109.18.208",
"port": 3000,
"protocol": "http",
"api": "api",
"devServiceWorker": false,
"useOutputCacheTagging": false,
"useOutputCache": false,
"outputCacheDefaultTtl": 86400,
"availableCacheTags": ["product", "category", "home", "checkout", "page-
not-found", "compare", "my-account", "P", "C", "error"],
"invalidateCacheKey": "aeSu7aip",
"dynamicConfigReload": false,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage",
"shipping", "boost", "query"],
"dynamicConfigInclude": [],
"elasticCacheQuota": 4096
},
"seo": {
"useUrlDispatcher": false
},
"console": {
"showErrorOnProduction" : true,
"verbosityLevel": "display-everything"
},
"redis": {
"host": "86.109.18.208",
"port": 6381,
"db": 0
},
"graphql":{
"host": "localhost",
"port": 8080
},
"elasticsearch": {
"httpAuth": "",
"host": "https://www.meubelplaats.nl/api/catalog",
"index": "vue_storefront_catalog",
"min_score": 0.02
}
With the custom-environment-variables.json
we can override the local.json
{
"server": {
"host": "PROD_SERVER"
},
"redis": {
"host": "PROD_SERVER",
"port": "REDIS_PORT"
},
"elasticsearch": {
"host": "ELASTIC_HOST"
}
}
{
"server": {
"host": "86.109.18.208",
"port": 3000,
"protocol": "http",
"api": "api",
"devServiceWorker": false,
"useOutputCacheTagging": false,
"useOutputCache": false,
"outputCacheDefaultTtl": 86400,
"availableCacheTags": ["product", "category", "home", "checkout", "page-
not-found", "compare", "my-account", "P", "C", "error"],
"invalidateCacheKey": "aeSu7aip",
"dynamicConfigReload": false,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage",
"shipping", "boost", "query"],
"dynamicConfigInclude": [],
"elasticCacheQuota": 4096
},
"seo": {
"useUrlDispatcher": false
},
"console": {
"showErrorOnProduction" : true,
"verbosityLevel": "display-everything"
},
"redis": {
"host": "86.109.18.208",
"port": 6381,
"db": 0
},
"graphql":{
"host": "localhost",
"port": 8080
},
"elasticsearch": {
"httpAuth": "",
"host": "https://www.meubelplaats.nl/api/catalog",
"index": "vue_storefront_catalog",
"min_score": 0.02
}
#!/usr/bin/env bash
export PROD_SERVER="localhost"
yarn install
yarn dev
With the custom-environment-variables.json
we can override the local.json
{
"server": {
"host": "86.109.18.208",
"port": 3000,
"protocol": "http",
"api": "api",
"devServiceWorker": false,
"useOutputCacheTagging": false,
"useOutputCache": false,
"outputCacheDefaultTtl": 86400,
"availableCacheTags": ["product", "category", "home", "checkout", "page-
not-found", "compare", "my-account", "P", "C", "error"],
"invalidateCacheKey": "aeSu7aip",
"dynamicConfigReload": false,
"dynamicConfigContinueOnError": false,
"dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage",
"shipping", "boost", "query"],
"dynamicConfigInclude": [],
"elasticCacheQuota": 4096
},
"seo": {
"useUrlDispatcher": false
},
"console": {
"showErrorOnProduction" : true,
"verbosityLevel": "display-everything"
},
"redis": {
"host": "86.109.18.208",
"port": 6381,
"db": 0
},
"graphql":{
"host": "localhost",
"port": 8080
},
"elasticsearch": {
"httpAuth": "",
"host": "https://www.meubelplaats.nl/api/catalog",
"index": "vue_storefront_catalog",
"min_score": 0.02
}
❏ Stop comparing the
local.json between local
machines
❏ And include the local.json,
custom-environment-
variables.json
Git Strategy
This didn’t work out very well...yikes!
Old way of ‘version control’
Current Git setup
Future setup
./scripts/start_local.sh
./scripts/rebuild_staging.sh
./scripts/rebuild_production.sh
#!/usr/bin/env bash
export PROD_SERVER="86.109.16.46"
export REDIS_PORT=6379
export ELASTIC_HOST="https://pwa.meubelplaats.nl/api/catalog"
export IMAGES_BASE_URL="https://pwa.meubelplaats.nl/img/"
# Some more settings
export PRODUCTS_ENDPOINT="https://pwa.meubelplaats.nl/api/product"
export ORDER_ENDPOINT="https://pwa.meubelplaats.nl/api/order"
export REVIEWS_ENDPOINT="https://pwa.meubelplaats.nl/api/review/create"
export STOCK_ENDPOINT="https://pwa.meubelplaats.nl/api/stock"
yarn
yarn build
yarn start
pm2 reload server
Easy building different types of environments
Custom theme
development
Use the default Vue Storefront theme as a basis.
Develop theme from scratch.
OR
Start with our custom theme development
❏ Copy the ‘base’ theme or develop a theme from
scratch.
❏ When the Vue Storefront core is updated, check the
update details and adjust your theme.
❏ No ‘Magento 2’ style fallback system in Vue
Storefront 1.x. Copy the entire base theme and
modify it as you see fit.
Comparison with M2 theme development
❏ Winner of the demo
theme competition
❏ Build by Absolute Web
Services
❏ Published on Github
❏ MIT license, so you can
use it as a basis
Good looking new Vuetique theme
✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server
✅ Setup Vue Storefront frontend & API
✅ Setup Magento 2 and added a new API user
✅ Indexer chosen and imported data to Elastic
✅ Ran the Node applications and kept them running
✅ Developed a custom theme
❓ Any other special client wishes?
❏ Integration with Sisow payment provider
❏ Payment surcharges
❏ Possible future shipping integration (PostNL, DPD, DHL)
Client wishes
We made the decision to stick with the Magento 2 checkout
Vue Storefront
with external
checkout
Used modules, all open source:
❏ https://github.com/Vendic/vsf-
external-checkout
❏ https://github.com/Vendic/magento2-
external-checkout
❏ https://github.com/Vendic/magento2-
checkout-only
Thanks to Filip and the VS core team
How does it work?
Sitemap.xml
generation
❏ The url structure of Vue Storefront is
different from Magento 2
❏ Our solution was a Magento 2 module that
generates a sitemap with Vue Storefront
urls
❏ Module is available for free on Github:
https://github.com/Vendic/magento2-
vuestorefront-xmlsitemap
❏ Complete with integration tests
✅ Installed NodeJS, HA Proxy, Redis & Elasticsearch on server
✅ Setup Vue Storefront frontend & API
✅ Setup Magento 2 and added a new API user
✅ Indexer chosen and imported data to Elastic
✅ Ran the Node applications and kept them running
✅ Developed a custom theme
✅ Any other special client wishes?
The end result… Tadaa!
Any questions?

More Related Content

What's hot

Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOdoo
 
itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2IT Expert Club
 
Shopware PWA - a technical overview of
Shopware PWA - a technical overview ofShopware PWA - a technical overview of
Shopware PWA - a technical overview ofSander Mangel
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...Chris Richardson
 
C* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel LiljencrantzC* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel LiljencrantzDataStax Academy
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Mario Fusco
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다Arawn Park
 
이것이 레디스다.
이것이 레디스다.이것이 레디스다.
이것이 레디스다.Kris Jeong
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample applicationAntoine Rey
 
Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshareMorten Andersen-Gott
 
빅데이터 분석 시스템 도입과 AI 적용
빅데이터 분석 시스템 도입과 AI 적용빅데이터 분석 시스템 도입과 AI 적용
빅데이터 분석 시스템 도입과 AI 적용BESPIN GLOBAL
 
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020Alex Thissen
 
Testing Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 worldTesting Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 worldYura Nosenko
 

What's hot (20)

react redux.pdf
react redux.pdfreact redux.pdf
react redux.pdf
 
Elk stack
Elk stackElk stack
Elk stack
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
 
itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2itlchn 20 - Kien truc he thong chung khoan - Phan 2
itlchn 20 - Kien truc he thong chung khoan - Phan 2
 
Shopware PWA - a technical overview of
Shopware PWA - a technical overview ofShopware PWA - a technical overview of
Shopware PWA - a technical overview of
 
Express JS
Express JSExpress JS
Express JS
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 
C* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel LiljencrantzC* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
C* Summit 2013: How Not to Use Cassandra by Axel Liljencrantz
 
Eloquent ORM
Eloquent ORMEloquent ORM
Eloquent ORM
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
 
이것이 레디스다.
이것이 레디스다.이것이 레디스다.
이것이 레디스다.
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshare
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
빅데이터 분석 시스템 도입과 AI 적용
빅데이터 분석 시스템 도입과 AI 적용빅데이터 분석 시스템 도입과 AI 적용
빅데이터 분석 시스템 도입과 AI 적용
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Vertx
VertxVertx
Vertx
 
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
 
Testing Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 worldTesting Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 world
 

Similar to Running Vue Storefront in production (PWA Magento webshop)

Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applicationsAstrails
 
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr TsapDive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr TsapProvectus
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gearsdion
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerNic Raboy
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Maarten Balliauw
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Spike Brehm
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivAmazon Web Services
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Amazon Web Services
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsSami Ekblad
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSRobert Nyman
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStackPuppet
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?Remy Sharp
 
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...Amazon Web Services
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCLFastly
 

Similar to Running Vue Storefront in production (PWA Magento webshop) (20)

Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr TsapDive into DevOps | March, Building with Terraform, Volodymyr Tsap
Dive into DevOps | March, Building with Terraform, Volodymyr Tsap
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...Sherlock Homepage - A detective story about running large web services - WebN...
Sherlock Homepage - A detective story about running large web services - WebN...
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJS
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStack
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
 
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...
Visibility into Serverless Applications built using AWS Fargate (CON312-R1) -...
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 

Recently uploaded

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Running Vue Storefront in production (PWA Magento webshop)

  • 3. Vue Storefront runs reliable in production! ❏ Live April 26th, 2019 ❏ No crashes or outages ❏ The minor issues we had in production were mostly in the configuration of Vue Storefront
  • 4. The ‘new’ technology stack for Magento 2 dev 1. 2. 3. 4. 5. 6. 7. 8. 9. And many other JavaScript libraries
  • 5. MVP: minimum VS instance connected to M2 STEP 2 Setup a M2 instance with products STEP 4 Pump the catalog into ElasticSearch STEP 1 Prepare the server STEP 3 Setup the VS components: frontend & API STEP 5 Start the VS frontend & API STEP 6 Start developing custom theme
  • 6. 1. Prepare the server We’re not using docker in production
  • 7. We will be working with Redis and ElasticSearch directly Redis will be used as a job queue system (Kue) 1. Prepare the server Elastic will hold our catalog data
  • 8. 1. Prepare the server
  • 9. 1. Prepare the server We use a reverse proxy (HAProxy) for SSL offloading and to serve the HTTP request to the right application
  • 10.
  • 11. The server is configured! Let’s install the apps. We skip step 2 (M2 setup) and fast forward to step 3.
  • 12. 3. Setup VS API 1. Clone the repo 2. Setup the local.json, which contains the settings 3. Add your Magento API credentials 4. Run yarn to install dependencies 5. Run yarn migrate to prepare elastic { "server": { "host": "localhost", "port": 8080, "searchEngine": "elasticsearch" }, "orders": { "useServerQueue": false }, "catalog": { "excludeDisabledProducts": false }, "elasticsearch": { "host": "localhost", "port": 9200, "protocol": "http", "user": "elastic", "password": "changeme", "min_score": 0.01, "indices": [ "vue_storefront_catalog", "vue_storefront_catalog_de", "vue_storefront_catalog_it" ], "indexTypes": [ "product", "category", "cms", "attribute", "taxrule", "review" ], "apiVersion": "5.6" }, "redis": { "host": "localhost", "port": 6379, "db": 0 }, "kue": {} }
  • 13. 3. Setup VS frontend 1. Clone the repo 2. Setup the local.json, which contains the settings 3. Add your VS API endpoints. If you use the demo API, skip this step 4. Run yarn to install dependencies { "server": { "host": "localhost", "port": 3000, "protocol": "http", "api": "api", "devServiceWorker": false, "useOutputCacheTagging": false, "useOutputCache": false, "outputCacheDefaultTtl": 86400, "availableCacheTags": ["product", "category", "home", "checkout", "page-not-found", "compare", "my-account", "P", "C", "error"], "invalidateCacheKey": "aeSu7aip", "dynamicConfigReload": false, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], "elasticCacheQuota": 4096 }, "seo": { "useUrlDispatcher": true } }
  • 14. Mage2VueStorefront OR VueStorefront Indexer for Magento 2 4. Import data from Magento 2 to VS
  • 15. Mage2VueStorefront ❏ A seperate Node app on the server ❏ Full reindexes of the Magento 2 catalog, pages and cms blocks ❏ Uses a products delta index that runs as a cron job to update changed data in Vue Storefront ❏ First release 2nd of june 2018 VueStorefront indexer ❏ Magento 2 extension installed via composer ❏ Adds Vue Storefront indexers to Magento 2 ❏ Runs with the Magento 2 default cron group ❏ First release on the 2nd of april 2019 4. Import data from Magento 2 to VS OR
  • 16. 1. Clone the mage2vs repo 2. Variables inserted via process.env global variables 3. Create a shell script to set the variables 4. Run the initial import 5. Setup the products delta indexer with a cron job #!/usr/bin/env bash export TIME_TO_EXIT=2000 export MAGENTO_CONSUMER_KEY=byv3730rhoulpopcq64don8ukb8lf2gq export MAGENTO_CONSUMER_SECRET=u9q4fcobv7vfx9td80oupa6uhexc27rb export MAGENTO_ACCESS_TOKEN=040xx3qy7s0j28o3q0exrfop579cy20m export MAGENTO_ACCESS_TOKEN_SECRET=7qunl3p505rubmr7u1ijt7odyialnih9 echo 'Default store - in our case United States / en' export MAGENTO_URL=http://demo-magento2.vuestorefront.io/rest export INDEX_NAME=vue_storefront_catalog node --harmony cli.js categories --removeNonExistent=true node --harmony cli.js productcategories --partitions=1 node --harmony cli.js attributes --removeNonExistent=true node --harmony cli.js taxrule --removeNonExistent=true node --harmony cli.js products --removeNonExistent=true --partitions=1 node --harmony cli.js reviews 4. Import data from Magento 2 to VS
  • 17. ✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server ✅ Setup Vue Storefront frontend & API ✅ Setup Magento 2 and added a new API user ✅ Indexer chosen and imported data to Elastic ❌ Ran the Node applications and kept them running ❌ Developed a custom theme
  • 19. { "apps": [ { "name": "frontend", "max_memory_restart": "4G", "instances": "4", "exec_mode": "cluster", "script": "./core/scripts/server.js", "node_args": "-- max_old_space_size=1024", "log_date_format": "YYYY-MM-DD HH:mm:ss", "ignore_watch": [ "core/build/config.json", "node_modules" ] } ] Command line tool for easy environment management with configuration files. Example ecosystem.json: PM2 Node Process Manager
  • 20. Nice overview of deployed apps with pm2 status PM2 Node Process Manager
  • 21. Other features include: ❏ Zero downtime deployments ❏ Application logging (logrotate) ❏ Application monitoring (memory and CPU) ❏ Up and down schaling of cluster processes PM2 Node Process Manager
  • 22. ✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server ✅ Setup Vue Storefront frontend & API ✅ Setup Magento 2 and added a new API user ✅ Indexer chosen and imported data to Elastic ✅ Ran the Node applications and kept them running ❌ Developed a custom theme
  • 25. { "server": { "host": "86.109.18.208", "port": 3333, "protocol": "http", "api": "api" } { "server": { "host": "localhost", "port": 3000, "protocol": "http", "api": "api" } Vue Storefront has hundreds of settings, it’s easy to overlook something. A unified configuration across multiple environments
  • 26. Vue Storefront uses https://github.com/lorenwest/node-config behind the scenes. A unified configuration across multiple environments
  • 27. { "server": { "host": "86.109.18.208", "port": 3000, "protocol": "http", "api": "api", "devServiceWorker": false, "useOutputCacheTagging": false, "useOutputCache": false, "outputCacheDefaultTtl": 86400, "availableCacheTags": ["product", "category", "home", "checkout", "page- not-found", "compare", "my-account", "P", "C", "error"], "invalidateCacheKey": "aeSu7aip", "dynamicConfigReload": false, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], "elasticCacheQuota": 4096 }, "seo": { "useUrlDispatcher": false }, "console": { "showErrorOnProduction" : true, "verbosityLevel": "display-everything" }, "redis": { "host": "86.109.18.208", "port": 6381, "db": 0 }, "graphql":{ "host": "localhost", "port": 8080 }, "elasticsearch": { "httpAuth": "", "host": "https://www.meubelplaats.nl/api/catalog", "index": "vue_storefront_catalog", "min_score": 0.02 } Our local.json contains: ❏ Environment specific data like IP addresses, ports and specific endpoints. ❏ Global settings (for example stock settings)
  • 29. { "server": { "host": "86.109.18.208", "port": 3000, "protocol": "http", "api": "api", "devServiceWorker": false, "useOutputCacheTagging": false, "useOutputCache": false, "outputCacheDefaultTtl": 86400, "availableCacheTags": ["product", "category", "home", "checkout", "page- not-found", "compare", "my-account", "P", "C", "error"], "invalidateCacheKey": "aeSu7aip", "dynamicConfigReload": false, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], "elasticCacheQuota": 4096 }, "seo": { "useUrlDispatcher": false }, "console": { "showErrorOnProduction" : true, "verbosityLevel": "display-everything" }, "redis": { "host": "86.109.18.208", "port": 6381, "db": 0 }, "graphql":{ "host": "localhost", "port": 8080 }, "elasticsearch": { "httpAuth": "", "host": "https://www.meubelplaats.nl/api/catalog", "index": "vue_storefront_catalog", "min_score": 0.02 } With the custom-environment-variables.json we can override the local.json { "server": { "host": "PROD_SERVER" }, "redis": { "host": "PROD_SERVER", "port": "REDIS_PORT" }, "elasticsearch": { "host": "ELASTIC_HOST" } }
  • 30. { "server": { "host": "86.109.18.208", "port": 3000, "protocol": "http", "api": "api", "devServiceWorker": false, "useOutputCacheTagging": false, "useOutputCache": false, "outputCacheDefaultTtl": 86400, "availableCacheTags": ["product", "category", "home", "checkout", "page- not-found", "compare", "my-account", "P", "C", "error"], "invalidateCacheKey": "aeSu7aip", "dynamicConfigReload": false, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], "elasticCacheQuota": 4096 }, "seo": { "useUrlDispatcher": false }, "console": { "showErrorOnProduction" : true, "verbosityLevel": "display-everything" }, "redis": { "host": "86.109.18.208", "port": 6381, "db": 0 }, "graphql":{ "host": "localhost", "port": 8080 }, "elasticsearch": { "httpAuth": "", "host": "https://www.meubelplaats.nl/api/catalog", "index": "vue_storefront_catalog", "min_score": 0.02 } #!/usr/bin/env bash export PROD_SERVER="localhost" yarn install yarn dev With the custom-environment-variables.json we can override the local.json
  • 31. { "server": { "host": "86.109.18.208", "port": 3000, "protocol": "http", "api": "api", "devServiceWorker": false, "useOutputCacheTagging": false, "useOutputCache": false, "outputCacheDefaultTtl": 86400, "availableCacheTags": ["product", "category", "home", "checkout", "page- not-found", "compare", "my-account", "P", "C", "error"], "invalidateCacheKey": "aeSu7aip", "dynamicConfigReload": false, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], "elasticCacheQuota": 4096 }, "seo": { "useUrlDispatcher": false }, "console": { "showErrorOnProduction" : true, "verbosityLevel": "display-everything" }, "redis": { "host": "86.109.18.208", "port": 6381, "db": 0 }, "graphql":{ "host": "localhost", "port": 8080 }, "elasticsearch": { "httpAuth": "", "host": "https://www.meubelplaats.nl/api/catalog", "index": "vue_storefront_catalog", "min_score": 0.02 } ❏ Stop comparing the local.json between local machines ❏ And include the local.json, custom-environment- variables.json
  • 33. This didn’t work out very well...yikes! Old way of ‘version control’
  • 36. ./scripts/start_local.sh ./scripts/rebuild_staging.sh ./scripts/rebuild_production.sh #!/usr/bin/env bash export PROD_SERVER="86.109.16.46" export REDIS_PORT=6379 export ELASTIC_HOST="https://pwa.meubelplaats.nl/api/catalog" export IMAGES_BASE_URL="https://pwa.meubelplaats.nl/img/" # Some more settings export PRODUCTS_ENDPOINT="https://pwa.meubelplaats.nl/api/product" export ORDER_ENDPOINT="https://pwa.meubelplaats.nl/api/order" export REVIEWS_ENDPOINT="https://pwa.meubelplaats.nl/api/review/create" export STOCK_ENDPOINT="https://pwa.meubelplaats.nl/api/stock" yarn yarn build yarn start pm2 reload server Easy building different types of environments
  • 38. Use the default Vue Storefront theme as a basis. Develop theme from scratch. OR Start with our custom theme development
  • 39. ❏ Copy the ‘base’ theme or develop a theme from scratch. ❏ When the Vue Storefront core is updated, check the update details and adjust your theme. ❏ No ‘Magento 2’ style fallback system in Vue Storefront 1.x. Copy the entire base theme and modify it as you see fit. Comparison with M2 theme development
  • 40. ❏ Winner of the demo theme competition ❏ Build by Absolute Web Services ❏ Published on Github ❏ MIT license, so you can use it as a basis Good looking new Vuetique theme
  • 41. ✅ Installed NodeJS, HA Proxy, Redis & ElasticSearch on server ✅ Setup Vue Storefront frontend & API ✅ Setup Magento 2 and added a new API user ✅ Indexer chosen and imported data to Elastic ✅ Ran the Node applications and kept them running ✅ Developed a custom theme ❓ Any other special client wishes?
  • 42. ❏ Integration with Sisow payment provider ❏ Payment surcharges ❏ Possible future shipping integration (PostNL, DPD, DHL) Client wishes We made the decision to stick with the Magento 2 checkout
  • 43. Vue Storefront with external checkout Used modules, all open source: ❏ https://github.com/Vendic/vsf- external-checkout ❏ https://github.com/Vendic/magento2- external-checkout ❏ https://github.com/Vendic/magento2- checkout-only Thanks to Filip and the VS core team
  • 44. How does it work?
  • 45. Sitemap.xml generation ❏ The url structure of Vue Storefront is different from Magento 2 ❏ Our solution was a Magento 2 module that generates a sitemap with Vue Storefront urls ❏ Module is available for free on Github: https://github.com/Vendic/magento2- vuestorefront-xmlsitemap ❏ Complete with integration tests
  • 46. ✅ Installed NodeJS, HA Proxy, Redis & Elasticsearch on server ✅ Setup Vue Storefront frontend & API ✅ Setup Magento 2 and added a new API user ✅ Indexer chosen and imported data to Elastic ✅ Ran the Node applications and kept them running ✅ Developed a custom theme ✅ Any other special client wishes?

Editor's Notes

  1. Today i’m going to tell you about the journey that we had with Meubelplaats, from the start. My name is Tjitse, i’m a backend developer at Vendic I’m my daily job i’m responsible for building integrations with Magento 2, but also making sure that our webshops are running smoothly
  2. We don't want to over complicate things in production, and add an extra layer of complexity with docker.
  3. That's why we are using Elastic and Redis directly without docker in between. We're used to working with both technologies in Magento 2 What we will have to do is: Install elasticsearch and run it on port 9200 Install redis and run it direclty on a port. Redis sockets didn’t work great with Kue in my experience.
  4. Desired architecture: We will start with Magento 2, the data is then loaded into elastic via the mage2vuestorefront datapump Elastic is used as storage, this is one of the reasons that VueStorefront is so fast. The catalog data is loaded into the system memory. The VueStorefront API gets all the catalog data from Elastic. Things like carts, orders, user registrations, stock data and images are not in elastic but are fetched directly from Magento 2 by using the REST API. I’m not entirely sure if there is already full GraphQL support, you can ask the core team this. The VueStorefront frontend is ran in cluster mode. In our case we have four different Nodes. This greatly improves the stability of our application. If one node crashes the others will take over.
  5. We use Haproxy for our more complicated Magento2 setup, so it did make sens to use this for VueStorefront The same can be acomplished with Nginx, it’s just a matter of taste
  6. We have four types of request: An image request that starts with /img, it will be passed to the VueStorefront API which then will fetch the image from Magento 2 An API request that stratrs with /api. It will be handled by the VueStorefront API running on port 8080 A request for Magento 2. In our case we are running Magento 2 on checkout.meubelplaats.nl. But I think you can easily run this on the same domain, but it would complicate the routing. A request for a static file in the Magento 2 route. For example robots.txt or sitemap.xml, maybe product feeds. A request for the VueStorefront frontend application running on port 3000. A big thanks to our server provider Magehost for helping out with the configuration and suggesting Haproxy.
  7. Since this is officially a MUG, i’ll skip the Magento 2 setup. Just setup a basic Magento 2.2 or 2.3 instance and create a new API user.
  8. The first thing we need to do when setting up the VueStorefront API is cloing the API repo ofcourse. The default configuration is stored in config/default.json. We can copy this to local.json and customize it as we see fit. The local.json stores all the settings. The connection to Magento 2 Custom VSF module that you have installed Multistore config
  9. The VueStorefront frontend setup is faily easy. Hopefully Filip has already explained this in the morning.
  10. We now want to import our catalog data into Elastic, this data will be used by the VueStorefront API. We can shoose from two different projects. One is the ‘old’ Mage2VueStorefront project, which is integrated into the VueStorefront API via NPM. Or we can use a Magento 2 extension that adds extra indexers to the project.
  11. Choose which one you like. We were already in the final stages of the project when the VueStorefront indexer was first launched. So we are using the Mage2VueStorefront module, which has worked reliable so far.
  12. You can import the data into Elastic by using one of the scripts that are included in the repository, or you can write your own script. Check the example script i’ve included.
  13. So how do we run NodeJS applications, and how do we keep them running? For Magento 2 developers that are used to working in a PHP env. this might be new. When you develop locally you just run yarn dev, what do we use in a production env?
  14. We use PM2 for this PM2 has tons of cool features, which I won’t talk about today One of the cool features is that you can add a ecosystem JS/JSON/YAML file to your project, which will add your deployment settings In our example we are running the VueStorefront frontend in cluster mode, with 4 instances. This means we have four different frontend applications We can always add more nodes if we want to increase capacity This greatly increases the performance and reliability of your applications, depending on the number of CPUs available. Under the hood, this uses the Node.js cluster module such that the scaled application’s child processes can automatically share server ports.
  15. PM2 status will give us an overview of the deployed apps It will give use basic stats per app, like mode status number of restarts uptime CPU usage memory usage
  16. This is one of the coolest things about headless development. Every frontend developer can connect to the same API VueStorefront This means a lightweight, disposable development enviroment. So no syncing of databases between staging and live No extra programs needed like mysql, elasticsearch, redis, varnish, php. Just NodeJS and Yarn. And no configuration issues The development environments are identical on every machine. This eliminates a lot of work and future problems.
  17. As most Magento 2 developer know, a lot can go wrong with configurations Most of the time an issue is just a yes/no toggle somewhere in the configuration “Ah it was just that flat catalog was turned on in production and not on my local machine” VueStorefront packs 100’s of settings, most of which are identical on every environment
  18. As most Magento 2 developer know, a lot can go wrong with configurations Most of the time an issue is just a yes/no toggle somewhere in the configuration “Ah it was just that flat catalog was turned on in production and not on my local machine” VueStorefront packs 100’s of settings, most of which are identical on every environment
  19. Behind the scenes a popular library Node Config is used
  20. Node config uses a default.json, which is overrided by a local.json
  21. With the custom-enviroments-variables.json we can override certain environment specific parts of the local.json Examples are: IP address Port The settings are only overwritten if the environment variables are set
  22. An example on how we start staging In the previous slide we’ve made the server host with the environment variable PROD_SERVER If we now set PROD_SERVER to localhost in a bash script And then run yarn dev on your local machine The server host is changed to localhost.
  23. So, if a team member want’s to change a configuration file. For example ‘synchonize carts’ to true. We can do this via a normal PR and every team member uses the same config. We also include all the files needed for development into version control This means every developer working on the frontend/api/mage2vs can start developing on their local machine and doesn’t have to worry about settings. The process is also repeatable, wich is great for CI
  24. This was a somewhat difficult topic. I saw a lot of questions about this in the VS slack
  25. In the beginning we just cloned the Vue Storefront repo Added our theme in the theme folder And adjusted the local.json This caused a lot of problems in the team, because we were working with three developers and multiple remote servers, all having their own local.json copy
  26. Our current setup works much better. We have a repo all the VueStorefront commits, with the official VueStorefront repo as an upstream branch Our own theme repository is add as a git submodule If you don’t like git submodules, that’s no problem You can also just develop under the /themes folder It was also easier to test things with Travis
  27. In the future it would be best to have the VS core as an NPM module And also the theme as a seperate NPM package This would be comparable with a modern Magento 2 composer setup.
  28. This allows us to have unified environments with a shared local.json. We start the application with a small shell script, containing only the settings that are changed for that specific environment. For example see the staging script that we use: For staging we use another VS API endpoint, which we can specify in the shell script
  29. Now to the theme development.
  30. This is comparable with Magento 2. When you start building a new theme, you must have some kind of base theme With VS it is also possible to develop your theme from scratch We thought it was the best to started with an emtpy base theme, and code everything ourselves After a few days of working on the new theme we quickly changed to using the default VueStorefront theme as a basis It saved us a lot of work.
  31. When we started out in with the Meubelplaats project, in the end of 2018, there we’re only two base themes available. The default VueStorefront theme, and I think it was a blue B2B theme. That i’ve not seen since then since In 2019 there are more and more new themes released, some are available on Github for free. For example the Vuetique theme
  32. At the time there weren’t plans to integrate Dutch payment service providers with VueStorefront . Our client wanted to integrate with Sisow, and Filip had already presentated the original external checkout module. So we decided to use his external checkout plugin, and contribute to it
  33. Our setup is composed of three modules: The VSF external checkout module, is a VueStorefront module that redirects to Magento 2 on checkout A Magento 2 module that receives the cart token and user token from VueStorefront (via a simple GET request), restores the cart and redirects to the M2 checkout. A Magento 2 module that runs in, what I call, checkout only mode. Any other frontend page will redirect to the VueStorefront homepage
  34. The solid lines represent the path of the user The dottet line represent data send between Magento 2 and VueStorefront
  35. VueStorefront uses a different URL structure. In our case it was: url/pagetype/sku|id/name+id We could have written some kind of scraper, but II had just had two great workshops on Magento 2 integration testing during MageTestFest in Florance, so I thought it would be more fun to practice TDD on a Magento 2 module and release it on Github.