| title | Deployment |
|---|---|
| excerpt | Learn how you can deploy your Jovo app to a server or cloud provider. |
| url | https://www.jovo.tech/docs/deployment |
Learn how you can deploy your Jovo app to a server or cloud provider.
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.
Learn more about the deployment process in the sections below:
Jovo uses esbuild to bundle and minify your src code. This results in:
- A
bundlefolder that includes a minifiedindex.jswith all code needed for the deployment. - A
bundle.zipfile with the contents of thebundlefolder 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:devThis 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 thebundlefolder.bundle: Usesesbuildto bundle the code into abundlefolder.postbundle: Executed afterbundle. Creates a ZIP file from thebundlefolder.
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.
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.