> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Run an Astro App

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](https://astro.build/) application on Fly.io.

You can deploy your [Astro](https://astro.build/) 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](/flyctl/install), the Fly.io CLI, and [sign up to Fly.io](/getting-started/sign-up-sign-in#first-time-or-no-fly-account-sign-up-for-fly) if you haven't already.

Next, if you don't have an existing Astro application, you can create one with the following command:

```bash theme={null}
npm create astro@latest
```

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.

<CodeGroup>
  ```bash cmd theme={null}
  cd my-astro-app
  fly launch
  ```

  ```output output theme={null}
  Scanning source code
  Detected an Astro app
  Creating app in [redacted]/my-astro-app
  We're about to launch your NodeJS app on Fly.io. Here's what you're getting:

  Organization: Your Name                (fly launch defaults to the personal org)
  Name:         my-astro-app             (derived from your directory name)
  Region:       Seattle, Washington (US) (this is the fastest region for you)
  App Machines: shared-cpu-1x, 1GB RAM   (most apps need about 1GB of RAM)
  Postgres:     <none>                   (not requested)
  Redis:        <none>                   (not requested)

  ? Do you want to tweak these settings before proceeding? (y/N) No
  Created app 'my-astro-app' in organization 'personal'
  Admin URL: https://fly.io/apps/my-astro-app
  Hostname: my-astro-app.fly.dev
  installing: npm install @flydotio/dockerfile@latest --save-dev

  ...

  found 0 vulnerabilities
       create  Dockerfile
  Wrote config file fly.toml
  Validating [redacted]/my-astro-app/fly.toml
  Platform: machines
  ✓ Configuration is valid

  ==> Building image
  ...
  --> Building image done
  ==> Pushing image to fly
  ...
  --> Pushing image done
  ...

  Watch your deployment at https://fly.io/apps/my-astro-app/monitoring

  Provisioning ips for my-astro-app
    Dedicated ipv6: 2a09:6739:1::30:xxxx:0
    Shared ipv4: 66.241.124.xxx
    Add a dedicated ipv4 with: fly ips allocate-v4

  This deployment will:
   * create 2 "app" machines

  No machines in group app, launching a new machine
  Creating a second machine to increase service availability
  Finished launching new machines
  -------
  NOTE: The machines for [app] have services with 'auto_stop_machines = true' that will be stopped when idling

  -------
  Checking DNS configuration for my-astro-app.fly.dev

  Visit your newly deployed app at https://my-astro-app.fly.dev/
  ```
</CodeGroup>

That's it! Run `fly apps open` to see your deployed app in action.

Try a few other commands:

* [`fly logs`](/flyctl/cmd/fly_logs) - Tail your application logs
* [`fly status`](/flyctl/cmd/fly_status) - View your app's current deployment status
* [`fly ssh console`](/flyctl/cmd/fly_ssh_console) - Open a terminal on your VM
* [`fly deploy`](/flyctl/cmd/fly_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`](https://docs.astro.build/en/guides/integrations-guide/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:

```bash theme={null}
npx astro add node
```

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](https://www.npmjs.com/package/@flydotio/dockerfile). 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.
