Skip to content

Deploy Astro to Coolify

For both (SSR and SSG), add this to Package.json, after ‘dependencies’ section, if not already set:

{
"dependencies": {
...
}
"engines": {
"node": ">=20.3.0"
}
}
  1. Go to https://apps.darideveloper.com/projects
  2. Create new project (if required) with project name, example: “project-name”
  3. Open the project
  4. Open “production” environment

Inside the project:

  1. Click in ”+ Add New Resource”
  2. Select “Public Repository”
  3. Paste github repository url
  4. Click in “Check Repository”
  5. In Build Pack select “Nixpacks”
  6. Click in “Save”
  1. Go to “General” tab
  2. Change name to repository name, example: “project-name”
  3. Update subdomain to repository name, example: “https://project-name.apps.darideveloper.com
  4. Press “Enter” at last field to save changes

Setup the follosing commands in each section:

Terminal window
# Install Command
npm i
# Build Command
npm run build

Go to “Environment Variables” tab inside the coolify app:

  1. Click in “Developer view”
  2. Setup all env variables from env file (copy and paste)
  3. Click in “Save All Environment Variables”
  4. Add the following env variable if not already set in your env files
Terminal window
NIXPACKS_NIXPKGS=nodejs_20,npm-9_x
  1. Go to “Advanced” tab
  2. Set “Custom Container Name” to project name, example: “project-name”
  3. Press “Enter” at last field to save changes

Follow this steps for server side rendering deployment only.

Install the folllowing package in the project

Install @astrojs/node package to use Node.js in Astro.

Be sure to setup as “standalone” mode

Build project and run it in local to validate it’s working

Terminal window
npm run build
node dist/server/entry.mjs
  1. Setup the follosing start command in coolify “General” tab
Terminal window
# Start Command
node ./dist/server/entry.mjs
  1. Set “Ports Exposes” to “3000”
  2. Press “Enter” at last field to save changes

Follow this steps for static site generation deployment only.

TODO

Follow this steps to enable auto deploy with coolify webhooks:

Enable Auto Deploy in Coolify