← Back to Guides
Profile image for Tom Snelling

By Tom Snelling

Published 31st August 2022

Deploy Astro on Northflank

Astro is an all-in-one web framework for building fast, content-focused websites.

This guide will show you how to get an Astro project built and deployed on Northflank.

Build and deploy your own Astro project

Add a Dockerfile

To deploy your Astro project on Northflank, you will need to add a Dockerfile to your repository. The simple example below builds the Astro app in the first stage, and then serves the output using the Caddy webserver.

/Dockerfile

FROM node:16 AS build
WORKDIR /app
COPY package.json package.json
COPY yarn.lock yarn.lock
COPY tsconfig.json tsconfig.json
RUN yarn install
COPY src ./src
COPY public ./public
COPY astro.config.mjs astro.config.mjs
RUN yarn build

FROM caddy:latest
COPY --from=build /app/dist /usr/share/caddy
EXPOSE 80

Create a Northflank service

In a new Northflank project, click the 'create new' button at the top of the page and select service. Choose a combined service to both build and deploy your repository. Give your service a sensible name.

Next, in the repository section, select your Astro repository and the branch that you want to build. Choose Dockerfile as the build type, and wait for your Dockerfile to be loaded.

Port 80 will automatically be detected as a public HTTP port and added to your networking configuration. Any other detected ports can be deleted, as they are not required to access your deployed site.

Finally, select an appropriate resource plan and create your service.

Once the service is created, a build will be started automatically. When the build succeeds, a new deployment will be created. You can access your running deployment via the auto generated code.run domain visible on the header in your service dashboard.

astro service.png

Start with our Astro template

The Northflank Astro template repository allows you to quickly deploy the Astro blog starter app.

In a new Northflank project, click the 'create new' button at the top of the page and select service. Click the link at the top of the form to create a service from a template, and select the Astro template. This will create a copy of northflank-guides/deploy-astro-on-northflank in your own VCS account. Select an appropriate resource plan, and create your service.

Once the service is created, a build will be started automatically. When the build succeeds, a new deployment will be created. You can access your running deployment via the auto generated code.run domain visible on the header in your service dashboard.

Demo

View the Astro blog starter deployed on Northflank

Deploy apps on Northflank for free

Northflank allows you to deploy your code and databases within minutes. Sign up for a Northflank account and create a free project to get started.

  • Deployment of Docker containers
  • Create your own stateful workloads
  • Persistent volumes
  • Observe & monitor with real-time metrics & logs
  • Low latency and high performance
  • Multiple read and write replicas
  • Backup, restore and fork databases

Share this article with your network