Skip to content

Latest commit

 

History

History
164 lines (140 loc) · 5.21 KB

zerops.mdx

File metadata and controls

164 lines (140 loc) · 5.21 KB
title description type i18nReady
Effettua il deploy del tuo sito Astro su Zerops
Come effettuare il deploy del tuo sito Astro usando Zerops.
deploy
true

import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro' import { Steps } from '@astrojs/starlight/components';

Zerops è una piattaforma cloud oriantata agli sviluppatori che può essere usata per eseguire il deploy del tuo sito SSR Astro.

Questa guida ti accompagnerà nel processo di deployment di un sito Astro su Zerops utilizzando l'adattatore specifico per Node.js.

Prerequisiti

:::tip[Iniziamo da un template] Il Zerops per Astro - esempio per Node.js può essere importato direttamente nella tua Dashboard di Zerops, e distribuito con un clic!

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

:::

Creare un progetto Zerops con Node.js

Puoi creare un servizio Node.js per il tuo sito Astro attraverso il Zerops project add wizard, o importando un sito Astro usando il .yaml.

La struttura dello YAML sottostante servirà per creare un progetto chiamato my-astro-sites con Node.js v20 con l'hostname hellothere. Un progetto Zerops può contenere più siti Astro.

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

Creare e distribuire la tua app su Zerops

Ora che abbiamo creato un servizio Node.js su Zerops, ti servirà creare il file zerops.yml nella directory principale del tuo progetto in modo da far avviare il processo di build e deploy alla pipeline di Zerops.

L'esempio sottostante mostra una configurazione che richiede alcune operazioni per il progetto example con l'hostname hellothere:

```yaml title="zerops.yml" 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 ``` ```yaml title="zerops.yml" zerops: - setup: hellothere build: base: nodejs@20 buildCommands: - pnpm i - pnpm run build deploy: - dist - package.json - node_modules cache: - node_modules - pnpm-lock.yaml run: start: node dist/server/entry.mjs envVariables: HOST: 0.0.0.0 NODE_ENV: production ``` ```yaml title="zerops.yml" 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 ```

Attivare il processo di build e deploy usando GitHub / GitLab

Per configurare il processo di build e deploy quando si fa un push a un branch o si crea una nuova release, vai al tuo servizio di Node.js e connetti il servizio di Zerops a una repository GitHub o GitLab.

Attivare il processo di build e deploy usando la CLI di Zerops (zcli)

1. Installa la CLI di Zerops. ```shell # Per scaricare il binario zcli direttamente, # usa https://github.com/zeropsio/zcli/releases npm i -g @zerops/zcli ```
  1. Vai su Settings > Access Token Management nell'app di Zerops e genera un nuovo token per accedere.

  2. Effetua il login usando il tuo access token usando il comando seguente: shell zcli login <token>

  3. Vai alla directory principale del tuo progetto (dove si trova il zerops.yml) e avvia il seguente comando per iniziare il deploy: shell zcli push

Risorse