Deploying Tonk Apps
This guide covers various deployment strategies for Tonk applications, from local containerization to cloud deployment on platforms like AWS EC2.
Overview
Tonk applications can be deployed in several ways:
- Local Development: Using
tonk -d
daemon for development - Docker Containerization: Packaging apps and the Tonk server in containers
- One-Touch Hosting: Using
tonk deploy
for managed hosting (experimental)
Docker Deployment
Tonk provides built-in Docker support for both the Tonk server and individual applications.
Tonk Server
The Tonk server is available as a pre-built Docker image at tonklabs/tonk-server:latest
. Pull and run the image with:
docker run -d \
--name tonk-server \
-p 7777:7777 \
-v tonk-data:/data/tonk \
tonklabs/tonk-server:latest
Tonk Apps
When you create a Tonk app using tonk create
, a docker-compose.yml
file is automatically included in your project. This file is pre-configured to work with your app.
-
Build your Tonk app:
cd my-tonk-app pnpm run build
-
Start the containers using the included configuration:
docker-compose up -d
-
Access your app:
- Tonk server: http://localhost:7777
- Your app: http://localhost:8000
Customizing Your Docker Setup
You can customize the included docker-compose.yml
file for your specific needs:
services:
tonk-server:
image: tonklabs/tonk-server:latest
container_name: tonk-server
volumes:
- tonk-data:/data/tonk/stores
- tonk-bundles:/data/tonk/bundles
- ./dist:/tmp/app-bundle
ports:
- "7777:7777"
- "8000:8000"
environment:
- PORT=7777
- NODE_ENV=production
- VERBOSE=false # Disable verbose logging for production
- SYNC_INTERVAL=30000 # Set sync interval to 30 seconds
restart: unless-stopped
# The command section handles app deployment automatically
Environment Configuration
The Tonk server Docker image supports several environment variables:
Variable | Default | Description |
---|---|---|
PORT | 7777 | Port for the Tonk server |
BUNDLES_PATH | /data/tonk/bundles | Directory for storing app bundles |
STORES_PATH | /data/tonk/stores | Directory for storing data |
CONFIG_PATH | /data/tonk/config | Directory for configuration files |
VERBOSE | true | Enable verbose logging |
SYNC_INTERVAL | 0 | Sync interval in milliseconds |
NODE_ENV | production | Node.js environment |
Troubleshooting
Common Issues
- Port conflicts: Ensure ports 7777 and 8000 are available
- Permission issues: Check file permissions for data directories
- Network connectivity: Verify security group settings
- Resource limits: Monitor CPU and memory usage
Debugging Commands
# Check container logs
docker logs tonk-server
# Check container status
docker ps
# Check Tonk server health
curl http://localhost:7777/ping
# Check running bundles
tonk ps
One-Touch Hosting (Experimental)
⚠️ EXPERIMENTAL FEATURE ⚠️
The tonk deploy
command provides experimental one-touch hosting for Tonk applications. This feature is highly experimental and will change drastically. Expect data loss. You must obtain an access code to use this feature (see below).
Usage
In your Tonk app directory run:
tonk deploy
Options:
-n, --name <name>
: Name for the deployed app (defaults to package.json name)-r, --region <region>
: Region to deploy to (default: ord)-m, --memory <memory>
: Memory allocation (e.g., 256mb, 1gb) (default: 1gb)-c, --cpus <cpus>
: Number of CPUs (default: 1)--skip-build
: Skip the build step--remote
: Use remote Docker build
Important Warnings
- Data Loss: Your deployed applications and data may be lost at any time
- Breaking Changes: The deployment architecture will change soon
- No SLA: This is an experimental service with no uptime guarantees
- Access Required: You must have a valid deploy code from Tonk
How It Works
- Builds your Tonk application locally
- Creates a compressed bundle of your project
- Uploads the bundle to Tonk's hosting service
- Returns a public URL for your deployed application
Getting Access
Contact Jack at Tonk (Telegram) to request a deploy code.
Next Steps
- Explore Tonk Workers for background processing