After developing or testing new features, for any particular Venia environment on developer mode, the next step is to deploy to production mode in order to take full advantage of the customized and enhanced code for being used as a Magento frontend.
This article will not cover any CI/CD process, due to its dependency and dynamic nature based on custom requirements and testing.
- Installing Venia
1.1 Before Installation
Need to check both Node and Yarn versions on the host; being the following version the minimum required.
node -v (Should be 10.16.3 or higher)
yarn -v (Should be 1.13.0 or higher)
If the host’s versions are lower, an update or reinstall is required.
For more information regarding specific OS installation steps can be found in the following links:
- In the local folder to be used as the root directory, create the initial project and answer the questions:
# yarn create @magento/pwa
- Start the dev server:
# yarn watch @magento/pwa
After this, the dev server will be ready to be used; however, it is recommended to create a custom hostname and SSL cert, especially if there are more than one environment being developed in the same local environment.
# yarn build create-custom-origin ./
After this, everytime the dev server starts will use a unique and customized hostname and SSL certificate.
If the dev requires a very specific hostname it can be changed in the .env file by setting changing the value for CUSTOM_ORIGIN_EXACT_DOMAIN
Note: everytime the hostname is modified the create-custom-origin command must be executed.
- Running Production Mode
After testing and developing all the required features, the Venia can be set now to production mode as follows:
1. Setting up .env params
The following params in the .env file need to be set up in order to run production mode properly.
STAGING_SERVER_PORT=xxxx —> for customizing the port number
CUSTOM_ORIGIN_EXACT_DOMAIN=”xxxxx” → for customizing the hostname
Before running production mode, the code needs to be compiled into the build folder.
# yarn run build
Finally, the production mode can start.
# yarn start
- Setting up NGINX
It is also recommended to deploy a Web server for enhancing security and performance.
Usually, ReactJs-based projects work better with NGINX. The following checklist needs to be followed:
- Static vs Proxy mode: Should NGINX be set as static or proxy mode? This depends on if NGINX will handle the whole request or just serve as a bridge for another software.
- Firewall Settings: Make sure that all ports configured for both Venia and NGINX are able to be accessed securely from any secure client.
- SSLCertificate: By default Venia requires to work with https
- URL rewrite may be necessary or not; depending on the NGINX and Server configuration.
For a full reference on how to comply with the checklist listed above, please refer to the following links. The NGINX configuration is relative to the OS and for these reasons they will not be covered in this article.