Zum Inhalt springen

Deploy your Astro Site to Zerops

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Zerops is a dev-first cloud platform that can be used to deploy both Static and SSR Astro site.

This guide will walk you through deploying of a static project and Node.js Project to Zerops.

Creating a Zerops Static project

Section titled Creating a Zerops Static project

First create a project using Zerops project add wizard then create a static service for your Astro project.

Pushing your static app to Zerops

Section titled Pushing your static app to Zerops

Now that you’ve prepared a Static service on Zerops, you will need to create a zerops.yml file at the root of your project to trigger the build and deploy pipeline on Zerops.

The following example shows the configuration of the required build and operations for the project with hostname app:

zerops.yml
zerops:
- setup: app # Should match with static service's name
build:
base: nodejs@20
buildCommands:
- npm i
- npm build
deployFiles:
- dist/~
cache:
- node_modules
- package-lock.json
run:
base: static

Now you can deploy this using zCli Trigger the pipeline using zcli or you can Or you can import a github/gitlab repository which already has a zerops.yml

Creating a Zerops Node.js project

Section titled Creating a Zerops Node.js project

You can create a Node.js service for your Astro site through the Zerops project add wizard, or by importing an Astro site using zerops-project-import.yaml.

Pushing your Node.js app to Zerops

Section titled Pushing your Node.js app to Zerops

Now that you’ve prepared a Node.js service on Zerops, you will need to create a zerops.yml file at the root of your project to trigger the build and deploy pipeline on Zerops.

The following example shows the configuration of the required build and operations for the project with hostname app:

zerops.yml
zerops:
- setup: app
build:
base: nodejs@20
buildCommands:
- npm i
- npm run build
deployFiles:
- dist
- package.json
- node_modules
cache:
- node_modules
- package-lock.json
run:
base: nodejs@20
ports:
- port: 3000
httpSupport: true
envVariables:
PORT: 3000
HOST: 0.0.0.0
start: npm start

There are three ways to deploy your astro app in Zerops.

Trigger the pipeline Using Zerops CLI (zcli)

Section titled Trigger the pipeline Using Zerops CLI (zcli)
  1. Install the Zerops CLI.

    Terminal window
    # To download the zcli binary directly,
    # use https://github.com/zeropsio/zcli/releases
    npm i -g @zerops/zcli
  2. Open Settings > Access Token Management in the Zerops app and generate a new access token.

  3. Log in using your access token with the following command:

    Terminal window
    zcli login <token>
  4. Navigate to the root of your app (where zerops.yml is located) and run the following command to trigger the deploy:

    Terminal window
    zcli push

Trigger the pipeline using GitHub / GitLab

Section titled Trigger the pipeline using GitHub / GitLab

To setup continuous deployment on either a push to a branch or on a new release, go to your Node.js service detail and connect your Zerops service with a GitHub or GitLab repository.

To setup continuous deployment on either a push to a branch or on a new release, go to your Node.js service detail and connect your Zerops service with a GitHub or GitLab repository.

  1. Importing for Node.js deployment.

    project:
    name: recipe-astro # creates a new project
    tags:
    - zerops-recipe
    # You can ignore the yaml above - if you already have project
    # Just go to the project and then navigate to import a service button
    services:
    - hostname: app # should match with zerops.yml service name
    type: nodejs@20
    enableSubdomainAccess: true
    buildFromGit: https://github.com/zeropsio/recipe-astro-nodejs
  2. Importing for Static deployment.

    project:
    name: recipe-astro # creates a new project
    tags:
    - zerops-recipe
    # You can use the below if you already have project
    # Just go to the project and then navigate to import a service button
    services:
    - hostname: app # should match with zerops.yml service name
    type: static@1.0 # should match with zerops.yml service name
    enableSubdomainAccess: true # enables zerops subdomain to preview the project
    buildFromGit: https://github.com/zeropsio/recipe-astro-static # you can replace with your github repo if the project has zerops.yml

Weitere Veröffentlichungs-Anleitungen