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.
Prerequisites
Section titled Prerequisites- An Astro project using the
@astrojs/node
SSR adapter (for Node.js Project) - zCli zerops cli (optional)
- A Zerops account - If you don’t already have one, you can create a Zerops account for free.
Creating a Zerops Static project
Section titled Creating a Zerops Static projectThe Zerops x Astro - Static example app can be imported directly into your Zerops Dashboard, and deployed in one click!
project: name: recipe-astro tags: - zerops-recipe
services: - hostname: app type: static@1.0 enableSubdomainAccess: true buildFromGit: https://github.com/zeropsio/recipe-astro-static
The following YAML structure will setup a project called recipe-astro with a static service called app.
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 ZeropsNow 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: - 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
zerops: - setup: app # Should match with static service's name build: base: nodejs@20 buildCommands: - pnpm i - pnpm build deployFiles: - dist/~ cache: - node_modules - pnpm-lock.yaml run: base: static
zerops: - setup: app # Should match with static service's name build: base: nodejs@20 buildCommands: - yarn - yarn build deployFiles: - dist/~ cache: - node_modules - yarn.lock 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
One Zerops project can contain multiple Astro apps.
Creating a Zerops Node.js project
Section titled Creating a Zerops Node.js projectThe Zerops x Astro - Node.js example app can be imported directly into your Zerops Dashboard, and deployed in one click!
project: name: recipe-astro tags: - zerops-recipe
services: - hostname: app type: nodejs@20 buildFromGit: https://github.com/zeropsio/recipe-astro-nodejs ports: - port: 4321 httpSupport: true enableSubdomainAccess: true minContainers: 1
The following YAML structure will setup a project called recipe-astro with a Node.js v20 service called app.
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 ZeropsNow 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: - 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
zerops: - setup: app build: base: nodejs@20 buildCommands: - pnpm i - pnpm run build deployFiles: - dist - package.json - node_modules cache: - node_modules - pnpm-lock.yaml run: base: nodejs@20 ports: - port: 3000 httpSupport: true envVariables: PORT: 3000 HOST: 0.0.0.0 start: pnpm start
zerops: - setup: app build: base: nodejs@20 buildCommands: - yarn - yarn build deployFiles: - dist - package.json - node_modules cache: - node_modules - yarn.lock run: base: nodejs@20 ports: - port: 3000 httpSupport: true envVariables: PORT: 3000 HOST: 0.0.0.0 start: yarn start
Deploying
Section titled DeployingThere 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)-
Install the Zerops CLI.
Terminal window # To download the zcli binary directly,# use https://github.com/zeropsio/zcli/releasesnpm i -g @zerops/zcli -
Open
Settings > Access Token Management
in the Zerops app and generate a new access token. -
Log in using your access token with the following command:
Terminal window zcli login <token> -
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 / GitLabTo 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.
Importing an Existing Project
Section titled Importing an Existing ProjectTo 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.
-
Importing for Node.js deployment.
project:name: recipe-astro # creates a new projecttags:- 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 buttonservices:- hostname: app # should match with zerops.yml service nametype: nodejs@20enableSubdomainAccess: truebuildFromGit: https://github.com/zeropsio/recipe-astro-nodejs -
Importing for Static deployment.
project:name: recipe-astro # creates a new projecttags:- zerops-recipe# You can use the below if you already have project# Just go to the project and then navigate to import a service buttonservices:- hostname: app # should match with zerops.yml service nametype: static@1.0 # should match with zerops.yml service nameenableSubdomainAccess: true # enables zerops subdomain to preview the projectbuildFromGit: https://github.com/zeropsio/recipe-astro-static # you can replace with your github repo if the project has zerops.yml
Resources
Section titled Resources- Deploying Astro to Zerops in 3 mins
- Zerops Docs: Detailed guide to creating a Zerops Node.js service