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

Minor: Zerops Deployment Guide #7973

Merged
merged 29 commits into from May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
61e6d8c
feat: zerops guide
nermalcat69 Apr 22, 2024
c9172c0
feat: link to "add new project"
nermalcat69 Apr 22, 2024
d616ecc
feat: fix link error
nermalcat69 Apr 22, 2024
1b4df23
tidyup
fxck Apr 22, 2024
08a6683
typo
fxck Apr 22, 2024
b21e304
typoe
fxck Apr 22, 2024
5d67ca1
typo
fxck Apr 22, 2024
3fe87f2
typo
fxck Apr 22, 2024
6e6ba0c
Merge pull request #1 from fxck/zerops-guide
nermalcat69 Apr 22, 2024
5bc29f6
feat: fix ports and httpsupport
nermalcat69 Apr 23, 2024
c7f14d9
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
edb3513
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
2fda240
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
37b85c0
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
20f1923
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
45d6d63
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
96cd880
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
2a46f5b
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
c270098
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
62d3824
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
c6912c7
fix url in resources
nermalcat69 May 4, 2024
c07917e
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
bcbb7d8
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
a8e1a90
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
d78938d
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
8ee8314
Update src/content/docs/en/guides/deploy/zerops.mdx
nermalcat69 May 4, 2024
9f154f1
Merge branch 'main' into zerops-guide
sarah11918 May 4, 2024
59e5cd3
wizard wizard!
sarah11918 May 5, 2024
9d5e553
Merge branch 'main' into zerops-guide
sarah11918 May 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions public/logos/zerops.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/DeployGuidesNav.astro
Expand Up @@ -43,6 +43,7 @@ const services: Service[] = [
{ title: 'Kinsta', slug: 'kinsta', supports: ['ssr', 'static'] },
{ title: 'Deta Space', slug: 'space', supports: ['ssr', 'static'] },
{ title: 'Zeabur', slug: 'zeabur', supports: ['ssr', 'static'] },
{ title: 'Zerops', slug: 'zerops', supports: ['ssr'] },
];
---

Expand Down
178 changes: 178 additions & 0 deletions src/content/docs/en/guides/deploy/zerops.mdx
@@ -0,0 +1,178 @@
---
title: Deploy your Astro Site to Zerops
description: How to deploy your Astro site to the web using Zerops.
type: deploy
i18nReady: true
---
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro'
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

[Zerops](https://zerops.io/) is a dev-first cloud platform that can be used to deploy an Astro site. As of April 2024, it only supports SSR deployments.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

This guide will walk you through deploying an Astro Node.js service to Zerops.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

## Prerequisites

- A Zerops account. If you don’t already have one, you can create an account for free.
- `@astrojs/node` package
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

:::tip[How about a one-click example?]
Import [Zerops x Astro - Node.js](https://github.com/zeropsio/recipe-astro-nodejs) example app into Zerops.
Open [Zerops Dashboard](https://app.zerops.io/dashboard/projects), click "Import project", paste ⬇️ — built, deployed, done.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved
```yaml
project:
name: astro
services:
- hostname: astronode
type: nodejs@20
buildFromGit: https://github.com/zeropsio/recipe-astro-nodejs
ports:
- port: 4321
httpSupport: true
enableSubdomainAccess: true
minContainers: 1
```
:::

### Creating your own Zerops project with Astro apps
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

You can either add project and your first Node.js service through the [project add](https://app.zerops.io/dashboard/project-add) wizard in Zerops app, or quickly by importing it using a yaml structure.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

```yaml
project:
name: my-astro-sites
services:
- hostname: hellothere
type: nodejs@20
ports:
- port: 4321
httpSupport: true
minContainers: 1
```

This will setup a project called `my-astro-sites`, with a Node.js v20 service called `hellothere`, which will be ready for you to deploy your Astro app into. One Zerops project can contain many Astro apps.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

### Setting Up Node.js SSR in your app
Zerops is using [`@astrojs/node`](/en/guides/integrations-guide/node/) package to run the app. Add it to your deps, if you haven't already, and modify your Astro config to utilize it.

Here are the necessary lines in your `astro.config.mjs` file:
```js title="astro.config.mjs"
import { defineConfig } from 'astro/config';
import node from "@astrojs/node";

export default defineConfig({
output: 'server',
adapter: node({
mode: "standalone"
}),
});
```

nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved
## Building and deploying your app to Zerops

Now that you you've set up your app and prepared a Node.js service on Zerops, we can trigger the build and deploy pipeline on Zerops.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

Start by describing how to build and run your app through `zerops.yml` file placed at the root of your codebase. `setup:` part should match the hostname your chose for your service, in case of our example - `hellothere`.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

<PackageManagerTabs>
<Fragment slot="npm">
```yaml
zerops:
- setup: hellothere
build:
base: nodejs@20
buildCommands:
- npm i
- npm run build
deploy:
- dist
- package.json
- node_modules
cache:
- node_modules
- package-lock.json
run:
start: node dist/server/entry.mjs
envVariables:
HOST: 0.0.0.0
NODE_ENV: production
```
</Fragment>
<Fragment slot="pnpm">
```yaml
zerops:
- setup: hellothere
build:
base: nodejs@20
buildCommands:
- pnpm i
- pnpm run build
deploy:
- dist
- package.json
- node_modules
cache:
- node_modules
- pnpm-lock.json
run:
start: node dist/server/entry.mjs
envVariables:
HOST: 0.0.0.0
NODE_ENV: production
```
</Fragment>
<Fragment slot="yarn">
```yaml
zerops:
- setup: astronode
build:
base: nodejs@20
buildCommands:
- yarn
- yarn build
deploy:
- dist
- package.json
- node_modules
cache:
- node_modules
- yarn.lock
run:
start: node dist/server/entry.mjs
envVariables:
HOST: 0.0.0.0
NODE_ENV: production
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved
```
</Fragment>
</PackageManagerTabs>

### Trigger the pipeline by connecting the service to GitHub / GitLab
To setup continuous deployment on either push to branch or a new release, go to your Node.js service detail and connect your Zerops service with either GitHub or GitLab repository.
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved


### Trigger the pipeline Using Zerops CLI (zcli)

1. Install Zerops CLI
```shell
# To download the zcli binary directly,
# use https://github.com/zeropsio/zcli/releases
npm i -g @zerops/zcli
```

2. Open [`Settigs > Access Token Management`](https://app.zerops.io/settings/token-management) in Zerops app, generate a new access token

3. Login
```shell
zcli login <token>
```

4. Navigate to your apps root (where zerops.yml is also placed)
```shell
zcli push
```
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved

## Resources

- [Deploying Astro to Zerops in 3 mins](https://medium.com/@arjun.js/how-to-deploy-astro-to-zerops-4230816a62b4)
- [Detailed guide to create a Node.js service](https://docs.zerops.io/nodejs/how-to/create)
- [Managing Environment Variables](https://docs.zerops.io/nodejs/how-to/env-variables)
- [Updating Internal Ports](https://docs.zerops.io/nodejs/how-to/ports)
nermalcat69 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/data/logos.ts
Expand Up @@ -87,6 +87,7 @@ export const logos = LogoCheck({
'kontent-ai': { file: 'kontent-ai.svg', padding: '.15em' },
keystatic: { file: 'keystatic.svg', padding: '0' },
zeabur: { file: 'zeabur.svg', padding: '.2em' },
zerops: { file: 'zerops.svg', padding: '.2em' },
apostrophecms: { file: 'apostrophecms.svg', padding: '.15em .15em' },
db: { file: 'db.svg', padding: '.1em' },
});
Expand Down