Mastro 👨‍🍳 Docs

Search results

Blog GitHub   Bluesky

Deploy to production

In the previous chapter, we’ve seen how to run a development server locally on your laptop. But since your laptop is not always running and connected to the internet, you need a server in some data center to host your production website. If you don’t want to deploy your website to production (where other people on the internet can see it), you can also skip this chapter for now.

Deploy static site with CI/CD

If you have a static site, you can deploy to GitHub Pages, Netlify, or any other CDN. You could even serve the files from a static file server like nginx.

Let’s look at how you can generate your static site within a Continuous Integration / Continuous Delivery (CI/CD) service. This ensures a reproducible environment (i.e. that it not only works on your computer), and makes sure that you haven’t forgotten to add any needed files to git (which can happen easily). Basically, this is just running the following command on the CI/CD server instead of on your laptop.

Depending on whether you use Deno or Node.js, and what your deploy target is, we may have exactly the right documentation for you. Otherwise you can probably adapt them to your use-case.

Deploy to
GitHub Pages
Deploy to
Cloudflare
Deploy to
Netlify
SSG with Deno docs docs docs
SSG with Node.js docs docs docs

Deploy server to production

Since static sites are completely pre-generated, they’re usually faster and cheaper to host than running a server. However, as we’ll see in the next couple of chapters, there are some things that you cannot do with a static site.

Since GitHub Pages only offers static site hosting, if you need to dynamically generate pages on-demand, you need a production server, as offered by Deno Deploy, Fly.io, Render, or any server that can run Deno, Node.js or Bun – even if it’s via Docker.

Basically it’s just running the following command on their server:

Deno
deno run --allow-read --allow-net --allow-env server.ts
Copied!
Node.js
node server.ts
Copied!
Bun
bun server.ts
Copied!

Be sure to run one of those in production and not deno/pnpm/bun run start, as those run with the --watch flag that restarts the server on file changes – great for local development, but unnecessary in production.

We don’t have specific docs for every combination of JavaScript runtime and hosting provider, but here are some starting points:

Deploy to Deno Deploy Deploy to Render
Server with Deno docs docs
Server with Node.js - docs
Server with Bun - docs

In the next chapter, let’s look at some fun things you can do with a server.