Deploy Resources

Deploy Resources

 

Introduction

You can deploy the resources of your project from the CLI to the remote console, after you have developed and tested them. This will update the project in the console with the latest code.

The three components that you can deploy from the CLI are: Client, Functions, and API Gateway rules that you developed in your local Catalyst project directory. You can deploy web client applications of all three types: Basic web apps, Angular apps, and React apps.

When you deploy resources from the CLI, they will only be available in the development environment of your Catalyst project. They will not affect the production environment of your application. To make the resources available in the production environment, you must deploy the project to production from the console.

You can also directly host your web client application from the Catalyst console, and create or upload functions directly in the console. You can also configure APIs in API Gateway directly in the console.

Note: You cannot deploy resources of your mobile applications using the Catalyst CLI. You can host mobile apps using Mobile Device Management.

Points to Remember:

  • A project can only be deployed successfully if its directory includes the client and the functions packages in the standard structure. The functions and client directories must contain the required configuration files in the standard format. For more information, refer to the Project Directory Structure help.
  • The catalyst.json file must be present in the project directory when the project is deployed using the CLI. It is not necessary to include this file when you are directly hosting the web client from the console.
  • The catalyst-user-rules.json file that contains the definitions of the API Gateway rules must be present in the project's home directory, if you require it to be deployed.
 

Deploy All Resources

To deploy your Catalyst project from the CLI to the remote console, execute the following command in your terminal from your project directory:

$ catalyst deploy
 

When you execute this command, it will deploy all deployable resources in your project directory by default. The CLI will consider the project that is active in your working directory. If any project other than the directory's base project is active in it, the CLI will display a warning informing you of it.

 

Deploy Functions

The functions are deployed first. The CLI will compile all the Java functions in your project directory before deploying them. The compiled Java class files available in their respective directories. The Node.js functions are deployed directly.

The CLI deploys each function individually. The CLI will display the status of each resource's deployment individually, indicating if it was successful or a failure.

The Basic I/O and Advanced I/O functions are deployed to the URLs displayed in the terminal, and you can access their endpoints from their URLs. The endpoints of the Cron, Event, and Integration functions are not accessible through URLs, as they are associated with cron jobs, event listeners, or external integrations respectively. The CLI will just display their deployment status.

Note: The /server/ part in the URL of a Catalyst application indicates a function. A Basic I/O function's URL contains an /execute after the function's name, whereas an Advanced I/O function's URL does not contain that keyword.
 

Deploy Client

The client directory is deployed next. This will generate the URL endpoint of the hosted web client, where you can access the application.  

The Basic web client will be deployed straight away.


 

Deploy Angular Applications

When you deploy an Angular app, the Catalyst plugin for your Angular app, zcatalyst-cli-plugin-angular, which is installed when the Angular app is initialized, will handle the deployment.

The chunk files representing your Angular components and services, such as the polyfills and runtime files, are generated. The build is generated after the chunk files are generated.

Angular applications are compiled and built into an output directory dist/. This folder will contain all the compiled files of your app, such as the entry point file, stylesheets, and templates of the HTML, CSS, JS or TS types in your app's source folder, src.

The deployment details will be updated in the workspace configuration file angular.json. These fall under the standard deployment procedure of Angular applications.

The CLI will display the deployment details of your Angular app. The URL endpoint of the deployed web client will be generated and displayed. You can open the application with this URL.


 

Deploy React Applications

When you deploy a React app, the Catalyst plugin for your React app, zcatalyst-cli-plugin-react, which is installed when the React app is initialized, will handle the deployment.

The plugin will enable the compilation of the React app. React applications are compiled and built into an output directory build/. This folder will contain all the compiled files your app, such as the HTML, stylesheet, JS and other files in your app's source folder src. The production-ready build is generated after the compilation.

If you had developed your React app in TypeScript, the code will be transpiled to JavaScript during the compilation. These fall under the standard deployment procedure of React applications.

The CLI will display the deployment details of your React app. The URL endpoint of the deployed web client will be generated and displayed. You can open the application with this URL.

Note:
  • The /app/ part in the URL of a Catalyst application indicates the client component. You can view the URLs of your application of both environments from the Environments settings section.
  • If you enter the application's URL in this format: https://project_domain_name.development.catalystserverless.com, it will automatically redirect you to the application's homepage that you have configured in the client-package.json file, in the development environment.
 

Deploy API Gateway

The API Gateway's JSON file is deployed last. This will update the API definitions in the remote console.

Note: If API Gateway is disabled for your project, the deployment of the API Gateway rules will be skipped.

Your project will now be synchronized with your online Catalyst account. You will be able to access the functions, web client, and updated API Gateway definitions that were deployed in the remote console.

 

Deploy Options

Catalyst CLI enables you to deploy only specific resources, such as just the client package, specific functions, or the API Gateway rules, using two deploy options. The following options are available for the catalyst deploy command.

Note: Besides these deploy options, you can also deploy specific resources from your project by navigating to the target folder where the resources are located and executing the catalyst deploy command from that folder. This can be used when the deployable resources are all located in the same directory. For example, if you want to deploy a particular function alone, you can navigate to the function's folder in the CLI and run the catalyst deploy command.

--only <targets>

The --only option allows you to define the specific resources to be deployed. You can use this with client, functions, or apig keywords. You can specify multiple resources separated by commas without any whitespace characters between them.  

For example, to deploy just the client directory, run the following command in your terminal:

$ catalyst deploy --only client
 

This initiates the deployment of the client directory alone. The deployment process is the same as discussed in the previous section.

You can also deploy a specific function or functions using the --only option. You must specify the names of the target functions in the command separated by commas as shown below:

$ catalyst deploy --only functions:InvoiceFetch,functions:CostAccounting
 

You can also deploy the client and certain functions, or API Gateway rules and certain functions, alone as shown below:

$ catalyst deploy --only functions:InvoiceSync,functions:CostAccounting,functions:FreightTracking
 

This will deploy only the specified resources from the project directory. 


 

--except <targets>

The --except option allows you to define the resources to be excluded from deployment. It will deploy all the resources except for the ones that you specify. 

For example, if you use the --except option with client, it will deploy only the functions directory and the API Gateway rules. You can execute this command in the following way:

$ catalyst deploy --except client
 

You can also use this option to exclude specific functions. For example:

$ catalyst deploy --except functions:InvoiceFetch,functions:PaymentStatusCheck,functions:CostAccounting
 

This will deploy all the other functions, the client, and the API Gateway rules.


 

--ignore-scripts

Catalyst enables you to automate the CLI and terminal command executions by defining scripts in the catalyst.json file in your project directory. You can define two lifecycle scripts to execute before and after the catalyst deploy command respectively: predeploy, postdeploy. You can learn more about the lifecycle and custom scripts from the Scripts help page.

If you use the --ignore-scripts option while executing the catalyst deploy command, the CLI will ignore the actions configured for the predeploy and postdeploy scripts in the catalyst.json file of your project directory. The deployment process will proceed without the execution of these lifecycle scripts.

You can use the --ignore-scripts option as follows:

$ catalyst deploy --ignore-scripts
 

The deployment process will be the same as discussed earlier.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocatalyst.com