Skip to main content
Getting an application running on Fly.io is essentially working out how to package it as a deployable image. Once packaged it can be deployed to the Fly.io platform. In this guide we’ll learn how to deploy an Astro application on Fly.io. You can deploy your Astro app on Fly.io with minimal effort, our CLI will do the heavy lifting. You can use your existing Astro app or you can create one from scratch. Astro applications can be served as either static pages or with server-side rendering (SSR). On this page you’ll find guides to deploying both varieties.

Deploy a static Astro site

First, install flyctl, the Fly.io CLI, and sign up to Fly.io if you haven’t already. Next, if you don’t have an existing Astro application, you can create one with the following command:
With the project setup out of the way, you’re ready to start deploying! If you don’t have a Dockerfile yet, fly launch will generate one for you, as well as prepare a fly.toml file.
That’s it! Run fly apps open to see your deployed app in action. Try a few other commands:

Deploy an Astro site with SSR

Astro supports server-side rendering (SSR) through the use of adapters. There are a handful of adapters that are officially maintained by the Astro team. When using the @astrojs/node adapter, Fly.io will automatically detect this during fly launch and if no existing Dockerfile is found, it will generate a new one with the appropriate start command and environment variables. You can add the necessary Node adapter like so:
This will install @astrojs/node and make the appropriate changes to your astro.config.* file in one step.

Generating your Astro Dockerfile

As discussed earlier, running fly launch will generate a Dockerfile for you if one does not already exist. Separately, you can also generate your Dockerfile using Dockerfile generator. Once installed, it can be run using npx @flydotio/dockerfile for Node applications or bunx @flydotio/dockerfile for Bun applications. You’ll see it referenced throughout this article for various use cases.