Deployment Guide
This guide covers how to deploy the Astro application to various environments.Prerequisites
Before deploying, ensure:- All tests pass (
pnpm test) - The build completes successfully (
pnpm build) - Required environment variables are set
- Convex backend is deployed
Environment Variables
The following environment variables should be set in your deployment environment:Deployment Options
1. Static Hosting (Recommended)
Astro supports static generation, which is the recommended approach for deploying this application.Build for Static Hosting
dist/ directory, which can be deployed to any static hosting service.
Deploy to Vercel
Deploy to Netlify
Deploy to GitHub Pages
dist/ directory to the gh-pages branch.
2. Server-Side Rendering (SSR)
For dynamic content that needs to be generated at request time, use SSR deployment.Build for SSR
Updateastro.config.mjs to use the appropriate adapter:
Deploy to Vercel with SSR
Add avercel.json file:
Deploy to Netlify with SSR
Create anetlify.toml file:
3. Docker Deployment
For containerized environments, use Docker:Build the Docker Image
Run the Docker Container
Deploying with Docker Compose
Create adocker-compose.yml file:
Convex Backend Deployment
Before deploying the frontend, you need to deploy the Convex backend:- Install the Convex CLI if you haven’t already:
npm install -g convex - Log in to Convex:
npx convex login - Initialize a new deployment:
npx convex init - Deploy the backend:
npx convex deploy
PUBLIC_CONVEX_URL environment variable.
Continuous Integration/Continuous Deployment (CI/CD)
GitHub Actions
Create a.github/workflows/deploy.yml file:
Post-Deployment Verification
After deploying, perform these checks:- Verify all pages load correctly
- Test authentication flow
- Check that Convex integration is working
- Verify all interactive components function properly
- Test responsiveness on different devices
- Run Lighthouse audit for performance and accessibility
Rollback Procedure
If issues are encountered after deployment:- For Vercel/Netlify: Use their dashboard to roll back to the previous deployment
- For Docker: Restart the container with the previous image version
- For Convex: Use
npx convex deploy --cmd rollbackto roll back to the previous deployment
Performance Monitoring
Set up monitoring for your deployed application:- Add Sentry for error tracking
- Set up LogRocket for session replay
- Configure Vercel Analytics or Google Analytics
Troubleshooting
Common Issues
- Static assets not loading: Check paths in the build output
- API calls failing: Verify environment variables are set correctly
- Authentication issues: Check Auth settings and secret keys
- SSR rendering errors: Look for server logs in your hosting provider
Getting Help
If you encounter issues not covered here:- Check the Astro documentation
- Post in the Astro Discord
- Search for similar issues in the Astro GitHub repository