A quick how-to guide on deploying your server-side rendered Astro projects to Fly.io.
Deploying Astro projects to Fly.io.
Introduction
In part one of the series we covered how to deploy static Astro projects to fly.io. Here in part two we will cover how to deploy server-side rendered Astro projects, and it’s just as easy if not easier!
Updating our Astro Project for SSR
Updating Docker & Fly Configurations
We are basically going to revert what we did to both files. Like I mentioned before this is actually easier than the static deployment.
One last thing we will need to do before we can deploy is update our start script in the package.json. When we run pnpm build their will be a dist/ that is output by Astro. In this directory you should find another directory called server/ with an entry.mjs file inside of it. This is the file that we will need to tell Docker to execute on Fly’s servers.
NOTE: Please note the addition of HOST=0.0.0.0 to the command. This is necessary as when we start the server Astro believes it is running locally so we end up with 127.0.0.1:3000. This is fine on your and my machine but on Fly this will not…fly…hahaha!
And with that we can run fly deploy and wait to visit our updated Astro project that is not server-side rendered.
Astro's content collection feature is a game changer for easily managing content in a type safe manner. It also can help to easily add related collections or data types through referencing. In this article I show how I implemented a related articles feature.
Cody is a Christian, USN Veteran, Jayhawk, and an American expat living outside of Bogotá, Colombia. He is currently looking for new opportunities in the tech industry.