Skip to content

将你的 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.

¥Create your container

  1. Log in to the Juno Console.

  2. Click the Launch a new satellite button (the container for your project) from the launchpad

  3. Enter a name and select Website

  4. Confirm with Create a Satellite

  5. The platform will then provision its resources.

  6. Once the process is complete, click Continue to access the overview page.

¥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.

juno.config.mjs
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 deployment

  1. From your Satellite’s overview, navigate to the Setup tab.

  2. Click on Add an access key.

  3. Generate a new key with the default option. Click Submit.

  4. 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.

  5. Create a deploy.yml file in the .github/workflows subfolder of your repo.

  6. Add the following workflow configuration:

    .github/workflows/deploy.yml
    name: Deploy to Juno
    on:
    workflow_dispatch:
    push:
    branches: [main]
    jobs:
    deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Check out the repo
    uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    with:
    node-version: 24
    registry-url: "https://registry.npmjs.org"
    - name: Install Dependencies
    run: npm ci
    - name: Deploy to Juno
    uses: junobuild/juno-action@main
    with:
    args: hosting deploy
    env:
    JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }}

¥CLI deployment

  1. Install the CLI

    终端窗口
    npm i -g @junobuild/cli
  2. Authenticate the CLI. This will open the Juno Console.

    终端窗口
    juno login
  3. In the browser window, click Authorize to grant permission.

  4. 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-starter

更多部署指南

Astro v5.16 中文网 - 粤ICP备13048890号