Skip to content

Examples

Working code examples for different frameworks

This directory contains complete, runnable examples of applications that can be deployed to Airbase. Each example includes all necessary files and documentation.

Available Examples

Node.js Express

Complete example guide available: Node.js Express

Description: REST API server with Express.js

What's included: - Complete working Express.js API code - Multi-stage Docker build - Health check endpoint - Environment variable configuration - RESTful API patterns with sample endpoints - Production best practices (Gunicorn, clustering) - Database integration examples

Tech stack: - Node.js 22 - Express.js 4.x - ESM (ES Modules)

Key features: - ✅ CSP-compliant (JSON API) - ✅ Multi-stage build for smaller images - ✅ Health check and logging - ✅ RESTful endpoints (GET, POST) - ✅ Error handling - ✅ Production-ready configuration


Python Streamlit

Complete example guide available: Python Streamlit

Description: Interactive data visualization dashboard using Streamlit

What's included: - Complete working Streamlit application code - Interactive data dashboard with charts - File upload functionality - CSP-compliant visualization with Plotly - Deployment instructions and troubleshooting - Performance optimization tips

Tech stack: - Python 3.13 - Streamlit 1.31.0 - Pandas 2.2.0 - Plotly 5.18.0 (CSP-compatible)

Key features: - ✅ CSP-compliant charting - ✅ Interactive widgets (sliders, inputs, date pickers) - ✅ CSV file upload - ✅ Real-time data visualization - ✅ Responsive layout - ✅ Production-ready configuration


Static Site (Figma Make)

Complete example guide available: Static Site (Figma Make)

Description: React-based static single-page application with Nginx

What's included: - Complete React + TypeScript application code - Multi-stage Docker build (Node builder + Nginx) - Client-side routing configuration - CSP-compliant Vite build - Nginx SPA configuration with try_files - Deployment instructions and troubleshooting - Performance optimization tips

Tech stack: - React 18.3 - TypeScript 5.4 - Vite 5.1 - Tailwind CSS 3.4 - React Router 6.22 - Nginx 1.28

Key features: - ✅ CSP-compliant (Vite builds external JS only) - ✅ Client-side routing with React Router - ✅ Multi-stage build for optimal image size - ✅ Static asset caching - ✅ Gzip compression - ✅ Figma Make integration guide


Planned Examples

Node.js Express

Description: Simple HTTP API server using Express.js Tech Stack: - Node.js 22 - Express.js 4.x - Basic routing and JSON responses

Planned features: - Health check endpoint - Environment variable usage - Non-root user configuration - Production-ready setup


Python Flask

Description: REST API server using Flask Tech Stack: - Python 3.13 - Flask 3.0 - JSON response handling

Planned features: - Health check endpoint - PORT environment variable handling - Proper user permissions - Production WSGI setup


Static Site (Figma Make)

Description: Static single-page application deployment Tech Stack: - React + TypeScript - Vite build tool - Nginx for serving

Planned features: - Multi-stage Docker build - Client-side routing support - Optimized production build - Static asset serving


Using These Examples

Quick Start

  1. Choose an example that matches your framework
  2. Copy the example directory to your workspace
  3. Update airbase.json with your project handle
  4. Run airbase container build
  5. Run airbase container deploy --yes

Customization

  • Modify application code to suit your needs
  • Update dependencies in package.json or requirements.txt
  • Add environment variables via .env files
  • Adjust instance type in airbase.json if needed

Testing Locally

Each example includes instructions for local development: - Node.js: npm install && npm start - Python: pip install -r requirements.txt && python app.py - Streamlit: pip install -r requirements.txt && streamlit run main.py - Static SPA: npm install && npm run dev

Example Structure

Each example follows this structure:

example-name/
├── README.md              # Comprehensive documentation
├── airbase.json          # Airbase configuration
├── Dockerfile            # Container build instructions
├── .dockerignore         # Build exclusions (if needed)
├── .env.example          # Environment variable template (if needed)
├── [app files]           # Application-specific code
└── [config files]        # Framework-specific configs

Best Practices Demonstrated

All examples demonstrate: - ✅ Proper Dockerfile structure for Airbase - ✅ Non-root user configuration (USER app) - ✅ Correct file ownership (chown app:app) - ✅ $PORT environment variable usage - ✅ Health check endpoints - ✅ Multi-stage builds where appropriate - ✅ Security best practices - ✅ Production-ready configurations

Contributing Examples

To add a new example: 1. Create a new directory under examples/ 2. Include all necessary files 3. Write a comprehensive README.md 4. Test the deployment on Airbase 5. Document any prerequisites or special configurations 6. Update this README.md with the new example

Status

  • Node.js Express example
  • Python Flask example (not planned)
  • Python Streamlit example
  • Static Site (Figma Make) example