Header

Deploying Astro with DeployHQ

Prerequisites:

  • A hosted server with Node.js and npm installed
  • An Astro project ready for deployment
  • A DeployHQ account

Using DeployHQ for Astro Deployments

DeployHQ simplifies the deployment process for Astro sites, automating builds and deployments.

Creating a DeployHQ Project

  1. Sign up and log in to your DeployHQ account
  2. Create a new project:
    • Go to Projects > New Project
    • Follow the wizard to connect your Git repository

Configuring a Deployment Server

  1. Create a new server:
    • Go to Servers > New Server
    • Name the server
    • Select SSH as the protocol
    • Enter the Hostname (server IP address)
    • Set the Username (e.g., deployhq)
    • Enable SSH key authentication:
      • On your server, run:
su - deployhq
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
  • Paste DeployHQ's public SSH key into the file
  • Save and close the file
  • Set permissions: chmod 600 ~/.ssh/authorized_keys
  • Set the Deployment Path: Specify the directory where your Astro project will be deployed
  • Enable zero-downtime deployments: This ensures smooth deployments without downtime
  • Set the Environment: Enter production
  • Enable automatic deployment: This triggers a deployment whenever there's a code change
  • Save the configuration

Configuring Build Commands

1- Create new Commands in the Build Pipeline:

# Install dependencies
cd %path% && npm install

# Build the Astro project
npm run build

2- Create new SSH Commands:

# If using a process manager like PM2
pm2 restart astro-app

# If using nginx, you might need to reload it
sudo systemctl reload nginx

Deploying Your Astro Project

  1. Click "Deploy Project" in the header
  2. Select the server and revision to deploy
  3. Click "Deploy" to initiate the deployment process

Additional Tips

  • Configure environment variables: Use DeployHQ's configuration files to securely store sensitive information like API keys or environment-specific settings
  • Static file handling: Ensure your server is configured to serve the static files from the dist directory (Astro's default build output directory)
  • Configure build options: You can customize the build command based on your Astro configuration (e.g., astro build --base=/subdirectory)
  • Monitor deployments: Keep track of deployment statuses and logs to identify and resolve issues promptly

Important Astro-Specific Considerations

  • Ensure your server is configured to handle static files correctly
  • If using SSR, make sure your server is set up to handle Node.js applications
  • Consider using adapter-specific deployment configurations if using Astro SSR adapters (like @astrojs/vercel or @astrojs/netlify)

By following these steps and customizing the configuration to your specific needs, you can effectively automate your Astro deployments with DeployHQ, ensuring smooth and reliable updates to your website.


Want to learn more about deployment or Astro? Check out our documentation or contact our support team for assistance.

Tree

Proudly powered by Katapult. Running on 100% renewable energy.