Deployment
Learn how you can deploy your Jovo app to a server or cloud provider.
Introduction
Jovo offers server integrations that allow you to run your Jovo app code on different servers and cloud providers, for example AWS Lambda.
This page details the process of bundling and deploying the code. Usually, this is done using the deploy:code
command, for example with the Serverless CLI integration.
Deployment Steps
Learn more about the deployment process in the sections below:
Bundle
Jovo uses esbuild
to bundle and minify your src
code. This results in:
- A
bundle
folder that includes a minifiedindex.js
with all code needed for the deployment. - A
bundle.zip
file with the contents of thebundle
folder that can then be deployed to a cloud provider.
Usually, the bundling is happening as part of the deploy:code
command. Under the hood, it calls the bundle:<stage>
script, for example:
# Bundle src files (stage: dev) $ npm run bundle:dev
This will bundle the files based on your app.dev.ts
stage config.
The stage specific scripts are usually created using the new:stage
command. For example, the dev
stage script looks like this in your package.json
file:
{ "bundle:dev": "npm run bundle -- src/app.dev.ts" }
The script calls the bundle
script together with an entry point, in this case the app.dev.ts
stage config. This makes sure that only dependencies used by the respective stage are used in the bundle.
bundle
includes the following scripts:
{ "prebundle": "rimraf bundle", "bundle": "esbuild --bundle --outfile=bundle/index.js --sourcemap --minify --keep-names --platform=node --target=node14 --format=cjs --external:aws-sdk --external:@oclif/* --external:@jovotech/cli*", "postbundle": "cd bundle && bestzip ../bundle.zip * && cd .." }
The scripts do the following:
prebundle
: Executed beforebundle
. Deletes thebundle
folder.bundle
: Usesesbuild
to bundle the code into abundle
folder.postbundle
: Executed afterbundle
. Creates a ZIP file from thebundle
folder.
If you need to make any changes to the bundle
folder before the ZIP file is created (for example, move some files into the directory), we recommend modifying the bundle
script.
Deploy
After the bundle.zip
file was created in the bundle step, it can be deployed to a cloud provider.
You can do that manually or by using your own scripts. We recommend using the deploy:code
command (for example with the Serverless CLI integration) because it does the bundling and deployment all in a single command.