Deploying ESP Applications
When your ESP application has been built, you can select just the files and directories that are required for deployment to the live site. For security, it is recommended that you not copy the entire ESP application tree. Rather select only the files and directories that are actually required for the production application.
One Step Deploy
$ expansive deploy
This copies the required files to the ./deploy directory. You can also specify a deploy directory on the command line. For example:
$ expansive deploy /tmp/upload
This copies the required files to the /tmp/upload directory.
Files and Directories
These are the default files and directories that expansive deploy will deploy to the ./deploy directory.
File/Directory | Contents |
---|---|
dist/ | Public web content for the ESP application. |
cache/ | This directory contains the compiled ESP controllers and pages. |
db/ | Application database directory. |
esp.json | The esp.json configures your ESP application. |
pak.json | The pak.json file defines the ESP application name and version. |
Customizing Deployment
The deploy command can be customized via the control.deploy property in the expansive.json file. For example:
{ control: { deploy: { from: [ "dist/**", "extra/*.pdf", "cache/*.dll", "cache/*.lib", "esp.json", "pak.json" ], to: "deploy", clean: true, script: '' } } }
Using control.deploy Properties
Property | Description |
---|---|
from | Array of source files. May contain wild-cards. Defaults to: ['dist/**', 'cache/*', 'pak.json', 'esp.json']. |
flatten | Do not preserve source directory structure. Defaults to false. |
to | Destination directory. Defaults to ./deploy. |
clean | Remove the prior contents of the destination directory. |
script | Script to run after copying any specified files. |
Remote Deployment
You can use the deploy.script property to upload to a remote server. This example below creates a compressed tar file of the deploy contents and then uses a HTTP put request to upload to a server.
{ control: { deploy: { script: ` require ejs.tar let file = Path('upload.tgz') Tar(file).create(Path('deploy').files('**', {directories: false})) let http = Http() http.put('http://example.com/' + file, file.readString()) if (http.status != 200) { throw 'Cannot upload "' + file + '". Bad http status: ' + http.status + '.' } ` } } }
Deploying to different Architectures
If you are deploying to a different machine architecture, you will need to either cross-compile for that target or compile the ESP application on the target. See Building for Target Systems for more details.