Deploying to Production

This tutorial teaches you how to deploy your Azu application to a production environment.

What You'll Learn

By the end of this tutorial, you'll know how to:

  • Configure your app for production

  • Build an optimized release binary

  • Set up a production server

  • Deploy with Docker

  • Configure SSL and security

Prerequisites

  • A working Azu application

  • Access to a Linux server or cloud platform

  • Basic knowledge of command line and servers

Step 1: Production Configuration

Create production settings in your application:

Step 2: Build for Production

Create a release build:

The --release flag enables optimizations and --no-debug removes debug symbols for a smaller binary.

Step 3: Environment Variables

Create a .env.production file (don't commit this):

Step 4: Docker Deployment

Create a Dockerfile:

Create docker-compose.yml:

Build and run:

Step 5: Systemd Service

For traditional server deployment, create /etc/systemd/system/user-api.service:

Enable and start the service:

Step 6: Nginx Reverse Proxy

Configure Nginx as a reverse proxy with SSL:

Enable the site:

Step 7: SSL with Let's Encrypt

Install and configure Certbot:

Step 8: Health Check Endpoint

Add a health check endpoint:

Step 9: Deployment Script

Create scripts/deploy.sh:

Step 10: CI/CD with GitHub Actions

Create .github/workflows/deploy.yml:

Production Checklist

Before going live:

Monitoring

Add a simple monitoring endpoint:

Security Headers

Add security middleware:

Key Takeaways

  1. Build optimized binaries with --release

  2. Use environment variables for configuration

  3. Run behind a reverse proxy (Nginx) for SSL

  4. Set up health checks for monitoring

  5. Automate deployments with CI/CD

  6. Enable security headers and HTTPS

Next Steps

Congratulations! You've completed the Azu tutorial series. Explore further:


Your application is production-ready! You now have a fully deployed, secure Azu application.

Last updated

Was this helpful?