Effettua il deploy del tuo sito Astro su Zerops
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
Sezione intitolata Prerequisiti- Un progetto Astro che usa l’adattatore
@astrojs/node
per il SSR - Un account Zerops - Se non ne hai già uno, puoi creare il tuo account Zerops gratuitamente.
Il Zerops per Astro - esempio per Node.js può essere importato direttamente nella tua Dashboard di Zerops, e distribuito con un clic!
project: name: astroservices: - 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
Sezione intitolata Creare un progetto Zerops con Node.jsPuoi 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-sitesservices: - hostname: hellothere type: nodejs@20 ports: - port: 4321 httpSupport: true minContainers: 1
Creare e distribuire la tua app su Zerops
Sezione intitolata Creare e distribuire la tua app su ZeropsOra 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
:
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
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
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
Sezione intitolata Attivare il processo di build e deploy usando GitHub / GitLabPer 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)
Sezione intitolata Attivare il processo di build e deploy usando la CLI di Zerops (zcli)-
Installa la CLI di Zerops.
Terminal window # Per scaricare il binario zcli direttamente,# usa https://github.com/zeropsio/zcli/releasesnpm i -g @zerops/zcli -
Vai su
Settings > Access Token Management
nell’app di Zerops e genera un nuovo token per accedere. -
Effetua il login usando il tuo access token usando il comando seguente:
Terminal window zcli login <token> -
Vai alla directory principale del tuo progetto (dove si trova il
zerops.yml
) e avvia il seguente comando per iniziare il deploy:Terminal window zcli push
Risorse
Sezione intitolata Risorse- Deploy di un sito Astro su Zerops in 3 minuti
- Guida dettagliata su come creare un servizio Node.js su Zerops