🚧 This documentation is not complete yet as Lagon is in development.
CLI

The easiest way to deploy and manage Functions is through our Command-line interface (opens in a new tab).

Installation

Lagon CLI is available for the following operating systems:

  • macOS (Intel and M1)
  • Linux (x64 and arm64)
  • Windows (x64)

We recommend installing the CLI globally, using the package manager of your choice. You will also need ESBuild (opens in a new tab) installed globally on your machine, as we use it to bundle your Function's code:

# NPM
npm install --global @lagon/cli esbuild
# Yarn
yarn global add @lagon/cli esbuild
# PNPM
pnpm install --global @lagon/cli esbuild

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 any time. For security, you will be asked to confirm that you 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:

  1. You will be prompted to select an Organization
  2. 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 accepts 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 <FOLDER> allows you to specify a path to 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:

# Create a new Deployment in production mode
lagon deploy ./index.ts --prod
# Create a new Function with a client file and some assets
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 accepts only one argument:

  • <FILE> path to a file containing the Function to list deployments.

Example:

lagon ls ./index.ts

lagon promote

Promote the given Deployment to production. Make sure you are logged in before proceeding. This command accepts the following arguments:

  • <FILE> path to a file containing the Function to promote a Deployment from.
  • <DEPLOYMENT_ID> the ID of the Deployment to promote.

Example:

lagon promote ./index.ts claxnlc230738q5pa7iximskm

lagon undeploy

Un-deploy a Deployment. Make sure you are logged in before proceeding. This command accepts 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 accepts 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 accepts 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 to start the server on. (Default: 127.0.0.1)
  • --port <PORT> allows you to specify a custom port to start the server on. (Default: 1234)
  • --env <FILE> 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 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:

# Run a local dev server on port 56565
lagon dev ./index.ts --port 56565
# Run a local dev server with a client file and some assets
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 same steps as lagon deploy, but skip the deployment part and instead writes the output to a local .lagon folder.

This command accepts the same arguments and options as lagon deploy and lagon build.

Examples:

lagon build ./server.tsx --client App.tsx --public ./assets
tree .lagon/
# .lagon/
#   index.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.

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, log in to your installation using lagon login.