将你的 Astro 站点部署到 Juno
Juno 是一个开源的无服务器平台,用于托管静态网站、构建 Web 应用以及运行无服务器函数,并具备自托管的隐私性和控制力。
¥Juno is an open-source serverless platform for hosting static websites, building web applications, and running serverless functions with the privacy and control of self-hosting.
创建你的容器
Section titled “创建你的容器”¥Create your container
-
Log in to the Juno Console.
-
Click the Launch a new satellite button (the container for your project) from the launchpad
-
Enter a name and select Website
-
Confirm with Create a Satellite
-
The platform will then provision its resources.
-
Once the process is complete, click Continue to access the overview page.
配置你的项目
Section titled “配置你的项目”¥Configure your project
你的 Astro 项目可以作为静态站点部署到 Juno。
¥Your Astro project can be deployed to Juno as a static site.
在项目根目录创建一个 juno.config.mjs 文件,并将 PROD_SATELLITE_ID 替换为你之前创建的 Satellite 的 ID。
¥Create a juno.config.mjs file at the root of your project, and replace the PROD_SATELLITE_ID with the ID of the Satellite you created earlier.
import { defineConfig } from '@junobuild/config';
/** @type {import('@junobuild/config').JunoConfig} */export default defineConfig({ satellite: { ids: { production: '<PROD_SATELLITE_ID>' }, source: 'dist', predeploy: ['npm run build'] }});¥How to deploy
你可以使用 GitHub Actions 或 CLI(命令行接口)进行部署。
¥You can deploy using either GitHub Actions or CLI (command line interface).
GitHub Actions 部署
Section titled “GitHub Actions 部署”¥GitHub Actions deployment
-
From your Satellite’s overview, navigate to the Setup tab.
-
Click on Add an access key.
-
Generate a new key with the default option. Click Submit.
-
Upon successful creation, a Secret token will be displayed. Copy the value and save it as an encrypted secret in your GitHub repository or organization, using the key
JUNO_TOKEN. -
Create a
deploy.ymlfile in the.github/workflowssubfolder of your repo. -
Add the following workflow configuration:
.github/workflows/deploy.yml name: Deploy to Junoon:workflow_dispatch:push:branches: [main]jobs:deploy:runs-on: ubuntu-lateststeps:- name: Check out the repouses: actions/checkout@v4- uses: actions/setup-node@v4with:node-version: 24registry-url: "https://registry.npmjs.org"- name: Install Dependenciesrun: npm ci- name: Deploy to Junouses: junobuild/juno-action@mainwith:args: hosting deployenv:JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }}
CLI 部署
Section titled “CLI 部署”¥CLI deployment
-
Install the CLI
终端窗口 npm i -g @junobuild/cli终端窗口 pnpm add -g @junobuild/cli终端窗口 yarn global add @junobuild/cli -
Authenticate the CLI. This will open the Juno Console.
终端窗口 juno login -
In the browser window, click Authorize to grant permission.
-
Deploy your site:
终端窗口 juno hosting deploy
¥Guides
¥Examples
使用现成的 Astro 模板快速搭建网站。
¥Quickly scaffold a website with a ready-made Astro template.
npm create juno@latest -- --template astro-starterpnpm create juno -- --template astro-starteryarn create juno -- --template astro-starter