Skip to content

将你的 Astro 站点部署到 Fly.io

你可以将 Astro 项目部署到 Fly.io,这是一个在靠近用户的地方运行全栈应用和数据库的平台。

¥You can deploy your Astro project to Fly.io, a platform for running full stack apps and databases close to your users.

¥Project Configuration

你的 Astro 项目可以作为静态站点或服务器端渲染站点(SSR)部署到 Fly.io。

¥Your Astro project can be deployed to Fly.io as a static site, or as a server-side rendered site (SSR).

¥Static Site

默认情况下,你的 Astro 项目是静态站点。你不需要任何额外的配置即可将静态 Astro 站点部署到 Fly.io。

¥Your Astro project is a static site by default. You don’t need any extra configuration to deploy a static Astro site to Fly.io.

¥Adapter for SSR

要在你的 Astro 项目中启用按需渲染并在 Fly.io 上部署,请添加 Node.js 适配器

¥To enable on-demand rendering in your Astro project and deploy on Fly.io, add the Node.js adapter.

¥How to deploy

  1. Sign up for Fly.io if you haven’t already.

  2. Install flyctl, your Fly.io app command center.

  3. Run the following command in your terminal.

    Terminal window
    fly launch

    flyctl will automatically detect Astro, configure the correct settings, build your image, and deploy it to the Fly.io platform.

¥Generating your Astro Dockerfile

如果你还没有 Dockerfile,fly launch 将为你生成一个,并准备一个 fly.toml 文件。对于 serverhybrid 项目,此 Dockerfile 将包含适当的启动命令和环境变量。

¥If you don’t already have a Dockerfile, fly launch will generate one for you, as well as prepare a fly.toml file. For server or hybrid projects, this Dockerfile will include the appropriate start command and environment variables.

你可以改为使用 Dockerfile 生成器 创建自己的 Dockerfile,然后使用命令 npx dockerfile(适用于 Node 应用)或 bunx dockerfile(适用于 Bun 应用)运行。

¥You can instead create your own Dockerfile using Dockerfile generator and then run using the command npx dockerfile for Node applications or bunx dockerfile for Bun applications.

¥Official Resources

More Deployment Guides

Astro 中文网 - 粤ICP备13048890号