Deployment
Flapi can be deployed in various ways depending on your needs. This guide covers deployment options from managed cloud services to self-hosted solutions.
Cloud Platforms
AWS App Runner
AWS App Runner provides a fully managed container service that makes it easy to deploy Flapi without managing infrastructure.
- Create a new App Runner service in AWS Console
- Choose "Container Registry" as source and enter:
ghcr.io/datazoode/flapi:latest
- Configure the service:
- Port: 8080
- CPU: 1 vCPU (recommended minimum)
- Memory: 2 GB (recommended minimum)
- Set your environment variables for database connections and other configurations
- Deploy and AWS will automatically provision HTTPS endpoints and handle scaling
Google Cloud Run
Cloud Run offers serverless container deployment with automatic scaling to zero.
- Pull and tag the Flapi image:
docker pull ghcr.io/datazoode/flapi:latest
docker tag ghcr.io/datazoode/flapi:latest gcr.io/[PROJECT_ID]/flapi
- Push to Google Container Registry:
docker push gcr.io/[PROJECT_ID]/flapi
- Deploy to Cloud Run:
gcloud run deploy flapi \
--image gcr.io/[PROJECT_ID]/flapi \
--platform managed \
--port 8080 \
--region [REGION] \
--allow-unauthenticated
Azure Container Apps
Azure Container Apps provides a managed Kubernetes-based environment.
- Create a Container App:
az containerapp create \
--name flapi \
--resource-group myResourceGroup \
--image ghcr.io/datazoode/flapi:latest \
--target-port 8080 \
--ingress external \
--min-replicas 1 \
--max-replicas 10
- Configure scaling rules and environment variables through Azure Portal or CLI
Hosting Providers
Vultr
Vultr offers a one-click Docker deployment:
- Create a new server with the "Docker" one-click app
- SSH into your server
- Run Flapi:
docker run -d \
--name flapi \
-p 8080:8080 \
-v $(pwd)/config:/config \
ghcr.io/datazoode/flapi:latest
STACKIT Kubernetes Engine (SKE)
Deploy on STACKIT's managed Kubernetes service:
- Create a Kubernetes deployment file
flapi.yaml
:
apiVersion: apps/v1
kind: Deployment
metadata:
name: flapi
spec:
replicas: 2
selector:
matchLabels:
app: flapi
template:
metadata:
labels:
app: flapi
spec:
containers:
- name: flapi
image: ghcr.io/datazoode/flapi:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: flapi
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: flapi
- Apply the configuration:
kubectl apply -f flapi.yaml
Hetzner
Using Hetzner's Docker-CE app:
- Create a new server with Docker-CE app
- SSH into your server
- Create a docker-compose.yml:
version: '3'
services:
flapi:
image: ghcr.io/datazoode/flapi:latest
ports:
- "8080:8080"
volumes:
- ./config:/config
restart: unless-stopped
- Start the service:
docker-compose up -d
Self-Hosted
Systemd Service
For running Flapi as a systemd service on Linux:
- Create a systemd service file
/etc/systemd/system/flapi.service
:
[Unit]
Description=Flapi REST API Service
After=network.target
[Service]
Type=simple
User=flapi
ExecStart=/usr/local/bin/flapi -c /etc/flapi/config.yaml
Restart=always
RestartSec=5
StartLimitInterval=0
WorkingDirectory=/etc/flapi
[Install]
WantedBy=multi-user.target
- Create necessary directories and user:
sudo useradd -r -s /bin/false flapi
sudo mkdir -p /etc/flapi
sudo chown flapi:flapi /etc/flapi
- Copy your configuration:
sudo cp config.yaml /etc/flapi/
sudo chown flapi:flapi /etc/flapi/config.yaml
- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable flapi
sudo systemctl start flapi
- Check service status:
sudo systemctl status flapi
For all deployment methods, remember to:
- Configure your database connections
- Set up proper monitoring
- Configure logging
- Set up health checks
- Implement proper backup strategies
Features
Key features of Flapi include:
- Quick REST API creation from SQL queries
- Multiple database support
- Built-in authentication
- Caching capabilities
- Parameter validation