The easiest way to deploy and manage Functions is through our Command-line interface (opens in a new tab).
Installation
The CLI is not stable yet, so you might encounter bugs. Please open an issue (opens in a new tab) if it's the case.
Lagon CLI is available for the following operating systems:
- macOS (Intel and M1)
- Linux (x64 and arm64)
- Windows (x64)
We recommend to install the CLI globally, using the package manager of your choice:
# NPM
npm install --global @lagon/cli
# Yarn
yarn global add @lagon/cli
# PNPM
pnpm install --global @lagon/cli
You will also be able to install it through Cargo (opens in a new tab) - Rust's package manager
- soon.
Usage
Once installed, execute the lagon
CLI to see all the commands available.
lagon login
Before being able to deploy and manage Functions, you will need to log in. Make sure you have already created an account. If you try to execute a command that requires being logged in, you will be warned and the command will be aborted.
To proceed, run lagon login
and follow the instructions.
lagon logout
If you want, you can log out at anytime. For security, you will be asked to confirm that you really want to log out.
To proceed, run lagon logout
and follow the instructions.
lagon deploy
Create a new Function or a new Deployment for the given files. Make sure you are logged in before proceeding. If you are executing the command for the first time:
- You will be prompted to select an Organization
- You will be able to link to an existing Function, or create a new one by specifying a name
If you then want to trigger a new Deployment, re-run the same command. This command accept the following arguments and options:
<FILE>
is the only required argument. It should be the path to a file containing and exporting a Function.--client, -c <CLIENT>
allows you to specify a path to an additional file to bundle as a client-side script.--public, -p <CLIENT>
allows you to specify a path a custom assets directory, that will be served at the root (/
) of the Function. (Default:public
)--production, --prod
allows you to deploy the Function in production mode. (Default:false
)
Examples:
lagon deploy ./index.ts
lagon deploy ./server.tsx --client App.tsx --public ./assets
lagon ls
List all the Deployments of the given Function. Make sure you are logged in before proceeding. This command accept only one argument:
<FILE>
path to a file containing the Function to list deployments of.
Example:
lagon ls ./index.ts
lagon promote
Promote the given Deployment to production. Make sure you are logged in before proceeding. This command accept the following arguments:
<FILE>
path to a file containing the Function to promote a Deployment from.<DEPLOYMENT_ID>
the ID of the Deployment to prmote.
Example:
lagon promote ./index.ts claxnlc230738q5pa7iximskm
lagon undeploy
Un-deploy a Deployment. Make sure you are logged in before proceeding. This command accept the following arguments:
<FILE>
path to a file containing the Function to undeploy a Deployment from.<DEPLOYMENT_ID>
the ID of the Deployment to undeploy.
Example:
lagon undeploy ./index.ts claxnlc230738q5pa7iximskm
lagon rm
Deleting a Function also deletes permanently all of its Deployments, statistics and logs.
Delete completely a Function. Make sure you are logged in before proceeding. This command accept only one argument:
<FILE>
path to a file containing the Function to undeploy.
Example:
lagon rm ./index.ts
lagon dev
Launch a local dev server, using the same Runtime as when deployed to the Cloud.
This command accept the same arguments and options as lagon deploy
and lagon build
. It can also accept the following options:
--hostname <HOSTNAME>
allows you to specify a custom hostname the start the server on. (Default:127.0.0.1
)--port <PORT>
allows you to specify a custom port the start the server on. (Default:1234
)--env <PATH>
allows you to specify an environment file (typically.env
) to use to inject environment variables.--allow-code-generation
allows you to enable code generation from strings (eval
/new Function
)
Although the dev
command uses the exact same Runtime as when deployed, the local HTTP server itself doesn't have the
same optimizations. As such, you shouldn't run a production environment on it, or run any kind of load
tests/benchmarks.
Examples:
lagon dev ./index.ts --port 56565
lagon dev ./server.tsx --client App.tsx --public ./assets
lagon build
For debugging purposes, you can build a Function and see its output without deploying it. Under the hood, lagon build
does the exact same steps as lagon deploy
, but skip the deployment part and instead writes the output to a local .lagon
folder.
This command accept the same arguments and options as lagon deploy
and lagon build
.
Examples:
lagon build ./server.tsx --client App.tsx --public ./assets
ls .lagon/ # server.js, App.js, assets/
lagon link
Link a local Function to a deployed one, without triggering a new Deployment. Make sure you are logged in before proceeding. This command accept only one argument:
<FILE>
path to a file containing the Function to list deployments of.
Example:
lagon link ./index.ts
Self-hosting configuration
If you are self-hosting Lagon, you will need to update the default site URL to the one used by your installation. To do so, find the configuration file located in ~/.lagon/config.json
:
{
"token": "**************",
"site_url": "https://dash.lagon.app" // Replace this field
}
Replace the site_url
field by the one configured during the installation. To verify if it's working correctly, login to your installation using lagon login
.