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:fly launch will generate one for you, as well as prepare a fly.toml file.
fly apps open to see your deployed app in action.
Try a few other commands:
fly logs- Tail your application logsfly status- View your app’s current deployment statusfly ssh console- Open a terminal on your VMfly deploy- Deploy the application after making changes
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:
@astrojs/node and make the appropriate changes to your astro.config.* file in one step.
Generating your Astro Dockerfile
As discussed earlier, runningfly 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.