diff --git a/.changeset/fresh-rabbits-sneeze.md b/.changeset/fresh-rabbits-sneeze.md new file mode 100644 index 000000000..d1def2550 --- /dev/null +++ b/.changeset/fresh-rabbits-sneeze.md @@ -0,0 +1,5 @@ +--- +'@lagon/docs': patch +--- + +Improve Deployments docs diff --git a/.changeset/silly-rules-bathe.md b/.changeset/silly-rules-bathe.md new file mode 100644 index 000000000..8a2adb7c6 --- /dev/null +++ b/.changeset/silly-rules-bathe.md @@ -0,0 +1,5 @@ +--- +'@lagon/docs': patch +--- + +Rename Static Files to Assets diff --git a/packages/docs/next.config.js b/packages/docs/next.config.js index 96d806672..b4278842e 100644 --- a/packages/docs/next.config.js +++ b/packages/docs/next.config.js @@ -2,6 +2,13 @@ const nextConfig = { reactStrictMode: true, swcMinify: true, + redirects: () => [ + { + source: '/cloud/static-files', + destination: '/cloud/assets', + permanent: true, + }, + ], }; const withNextra = require('nextra')({ diff --git a/packages/docs/pages/cloud/_meta.json b/packages/docs/pages/cloud/_meta.json index cffc1e905..01673b66f 100644 --- a/packages/docs/pages/cloud/_meta.json +++ b/packages/docs/pages/cloud/_meta.json @@ -1,12 +1,12 @@ { "deployments": "Deployments", - "logs": "Logs", + "assets": "Assets", "environment-variables": "Environment variables", - "cron": "Cron", - "static-files": "Static files", "domains": "Domains", + "logs": "Logs", + "cron": "Cron", "pricing": "Pricing", - "limits": "Limits", "regions": "Regions", + "limits": "Limits", "security": "Security" -} \ No newline at end of file +} diff --git a/packages/docs/pages/cloud/assets.mdx b/packages/docs/pages/cloud/assets.mdx new file mode 100644 index 000000000..8534e72c7 --- /dev/null +++ b/packages/docs/pages/cloud/assets.mdx @@ -0,0 +1,40 @@ +Lagon can host and serve assets such as images, CSS files, and JavaScript files. These assets are static files that are not generated dynamically by your Function. + +When deploying a Function, you can specify an assets directory using the [`--public` or `-p`](/cli#lagon-deploy) flag. This directory will be served by Lagon at the root of your Function's URL. + +## Automatic assets serving + +Let's say you have a Function inside an `index.ts` file, with a favicon and an image: + +``` +index.ts +public/ + favicon.ico + images/ + image.png +``` + +To deploy this Function with these asets, you can use the `-p` or `--public` flag: + +```bash +lagon deploy ./index.ts --public public +# Same as +lagon deploy ./index.ts -p public +``` + +Your Function is now deployed to `example.lagon.dev`. You can access the favicon and the image at the following URLs: + +- `example.lagon.dev/favicon.ico` +- `example.lagon.dev/images/image.png` + +In your HTML, you can reference these files using relative paths: + +```html + + + +``` + +## Limits + +The number and size of assets are limited to prevent abuses. [Learn more about the assets limits](/cloud/limits). diff --git a/packages/docs/pages/cloud/deployments.mdx b/packages/docs/pages/cloud/deployments.mdx index f53d383f0..dd0f8e8c7 100644 --- a/packages/docs/pages/cloud/deployments.mdx +++ b/packages/docs/pages/cloud/deployments.mdx @@ -1,33 +1,50 @@ import { Callout } from 'nextra-theme-docs'; -There are two types of deployments: **Production** and **Preview** deployments. [Default and custom Domains](/cloud/domains) always points to the current production Deployment. +## Deploying a new Function -Each Deployment is immutable, and always accessible via a unique URL. You can see the list of Deployments for a Function in the "Deployments" tab of a Function: +A Function is bound to Deployments: **Production** and **Preview** deployments. [Default and custom Domains](/cloud/domains) always points to the current production Deployment. -![Deployments](/images/deployments.png) +Your Function always has a single production Deployment and typically has multiple preview Deployments. Each Deployment is immutable, and always accessible via a unique URL. -In this list, you can see the current production Deployment, the date at which each Deployment was created, their always-accessible URLs, and the author of each Deployment. +### Using the CLI + +You can deploy a new Function using the `lagon deploy` command: + +```bash +lagon deploy your-file.ts +``` + +This will create a new Function and a new production Deployment. You can then deploy again this Function using the same command: By default, `lagon deploy` will create a preview Deployment. You can use the `--prod` flag to automatically promote this new Deployment to production. -## Promoting a Deployment +```bash +# Create a preview deployment +lagon deploy your-file.ts +# Create a production deployment +lagon deploy --prod your-file.ts +``` - - You can't promote a production Deployment, as it is already the current production Deployment. - +Follow the [`lagon deploy` documentation](/cli#lagon-deploy) to learn more. + +### Using the GitHub Action + +If you are using GitHub and want to automate your Deployments with [GitHub Actions](https://github.com/features/actions), you can use the [Lagon GitHub Action](https://github.com/lagonapp/github-action). + +Follow the [Lagon GitHub Action documentation](https://github.com/lagonapp/github-action) to learn more. -You can roll back at any time to a previous or a new preview Deployment: +### Using the Dashboard -To promote a preview Deployment to production, click on the "Promote" button next to the preview Deployment you want to promote. You will be asked to confirm, and then this Deployment will be promoted and become the new production Deployment. The previous production Deployment will still exist but as a preview Deployment. +You can also create Functions and Deployments through the [Dashboard](https://dash.lagon.app), using the Playground. -## Deleting a Deployment +Head over to the [Dashboard](https://dash.lagon.app), and click on the "Create a Function" button. You will be redirected to the Playground, where you can see your new Function, with the code at the left and the deployed result at the right: -You can't delete a production Deployment. +![Playground](/images/playground.png) -You can delete a preview Deployment at any time. To do so, click on the "Delete" button next to the preview Deployment you want to delete. You will be asked to confirm, and then this Deployment will be deleted. +You can now edit the code in the Playground, and click on the "Deploy" button to create a new production Deployment.You will see the result of your changes at the right. ## Cold starts diff --git a/packages/docs/pages/cloud/static-files.mdx b/packages/docs/pages/cloud/static-files.mdx deleted file mode 100644 index 854d2d267..000000000 --- a/packages/docs/pages/cloud/static-files.mdx +++ /dev/null @@ -1,37 +0,0 @@ -Static files are automatically served by Lagon, without additional logic or configuration needed. - -When deploying a Function, you can add static files using the [`--public` or `-p`](/cli#lagon-deploy) flag. It accepts a path to a directory, which will be then served by Lagon at the root of your Function's URL. - -## Automatic static files serving - -Let's say you have a Function inside an `index.ts` file, with a favicon and an image: - -``` -index.ts -public/ - favicon.ico - images/image.png -``` - -To deploy this Function with these static files, you can use the `-p` or `--public` flag: - -```bash -lagon deploy ./index.ts -p public -``` - -Your Function is now deployed to `example.lagon.dev`. You can access the favicon and the image at the following URLs: - -- `example.lagon.dev/favicon.ico` -- `example.lagon.dev/images/image.png` - -In your HTML, you can reference these files using relative paths: - -```html - - - -``` - -## Optimizations - -All static files are automatically compressed with [Gzip](https://en.wikipedia.org/wiki/Gzip). A `Cache-Control` header is automatically set to `max-age=604800` (7 days) to enable caching by browsers. diff --git a/packages/docs/public/images/deployments.png b/packages/docs/public/images/deployments.png deleted file mode 100644 index 532a1077e..000000000 Binary files a/packages/docs/public/images/deployments.png and /dev/null differ diff --git a/packages/docs/public/images/playground.png b/packages/docs/public/images/playground.png new file mode 100644 index 000000000..912d20d96 Binary files /dev/null and b/packages/docs/public/images/playground.png differ