Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): improve Deployments and Static Files docs #738

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-rabbits-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lagon/docs': patch
---

Improve Deployments docs
5 changes: 5 additions & 0 deletions .changeset/silly-rules-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lagon/docs': patch
---

Rename Static Files to Assets
7 changes: 7 additions & 0 deletions packages/docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
redirects: () => [
{
source: '/cloud/static-files',
destination: '/cloud/assets',
permanent: true,
},
],
};

const withNextra = require('nextra')({
Expand Down
10 changes: 5 additions & 5 deletions packages/docs/pages/cloud/_meta.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
40 changes: 40 additions & 0 deletions packages/docs/pages/cloud/assets.mdx
Original file line number Diff line number Diff line change
@@ -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
<link rel="icon" href="/favicon.ico" />
<!-- ... -->
<img src="/images/image.png" />
```

## Limits

The number and size of assets are limited to prevent abuses. [Learn more about the assets limits](/cloud/limits).
43 changes: 30 additions & 13 deletions packages/docs/pages/cloud/deployments.mdx
Original file line number Diff line number Diff line change
@@ -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:

<Callout type="info">
By default, `lagon deploy` will create a preview Deployment. You can use the `--prod` flag to automatically promote
this new Deployment to production.
</Callout>

## Promoting a Deployment
```bash
# Create a preview deployment
lagon deploy your-file.ts
# Create a production deployment
lagon deploy --prod your-file.ts
```

<Callout type="warning">
You can't promote a production Deployment, as it is already the current production Deployment.
</Callout>
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:

<Callout type="warning">You can't delete a production Deployment.</Callout>
![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

Expand Down
37 changes: 0 additions & 37 deletions packages/docs/pages/cloud/static-files.mdx

This file was deleted.

Binary file removed packages/docs/public/images/deployments.png
Binary file not shown.
Binary file added packages/docs/public/images/playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.