This guide covers setting up and running Tron locally for development.
- Docker
- Docker Compose
- Make (optional, but recommended)
Run a single command to start the entire development environment:
make startThis command will:
- ✅ Start the FastAPI API (http://localhost:8000)
- ✅ Start the React Portal (http://localhost:3000)
- ✅ Start the PostgreSQL database
- ✅ Start the Kubernetes cluster (K3s)
- ✅ Run database migrations
- ✅ Load initial templates
- ✅ Create default administrator user
- ✅ Configure API token
- ✅ Create "local" environment
- ✅ Configure local cluster
After running make start, access:
Default credentials:
- Email:
admin@example.com - Password:
admin
API Documentation: http://localhost:8000/docs
# Start environment
make start
# Stop environment
make stop
# Restart environment
make restart
# View logs
make logs
# Check service status
make status
# Rebuild images
make build
# Run all tests
make test
# Run API tests only
make api-test
# Run Portal tests only
make portal-test
# Create new migration
make api-migration
# Apply migrations
make api-migrateIf you prefer not to use Make:
cd docker
# Start all services
docker compose up -d
# Start specific services
docker compose up -d database api
# View logs
docker compose logs -f api
# Run tests
docker compose run --rm api-test
docker compose run --rm portal-test
# Stop all services
docker compose downTo interact with the local K3s cluster:
export KUBECONFIG=./volumes/kubeconfig/kubeconfig.yaml
kubectl get nodes
kubectl get pods -AThe development environment includes a fully configured Gateway API setup with Traefik, supporting both HTTP and HTTPS.
| Port | Service | Description |
|---|---|---|
| 3000 | Portal | React frontend |
| 8000 | API | FastAPI backend |
| 5432 | PostgreSQL | Database |
| 5443 | K3s API | Kubernetes API |
| 8080 | Gateway HTTP | Traefik HTTP (Gateway API) |
| 8443 | Gateway HTTPS | Traefik HTTPS (Gateway API, self-signed cert) |
The Gateway is configured with two listeners:
- HTTP (port 80, exposed as 8080): For unencrypted traffic
- HTTPS (port 443, exposed as 8443): For encrypted traffic with a self-signed certificate
The self-signed certificate is valid for localhost and *.localhost.
-
Start the environment:
make start
-
Access the Portal at http://localhost:3000 and login with
admin@example.com/admin -
Create a test application:
- Go to Applications → Create Application
- Name:
test-app - Create an Instance in the
localenvironment - Add a webapp component with:
- Name:
web - Image:
nginx:alpine - Visibility:
Public - Public URL:
test.localhost
- Name:
-
Deploy the component and wait for it to be running
-
Test Gateway API access:
# Test HTTP via curl with Host header curl -H "Host: test.localhost" http://localhost:8080 # Test HTTPS (use -k to accept self-signed certificate) curl -k -H "Host: test.localhost" https://localhost:8443 # Or add to /etc/hosts and access directly echo "127.0.0.1 test.localhost" | sudo tee -a /etc/hosts curl http://test.localhost:8080 curl -k https://test.localhost:8443
export KUBECONFIG=./volumes/kubeconfig/kubeconfig.yaml
# Check Gateway
kubectl get gateway -A
# Check Gateway listeners
kubectl get gateway -n kube-system gateway -o jsonpath='{.spec.listeners[*].name}'
# Check HTTPRoutes created by Tron
kubectl get httproute -A
# Check TLS certificate secret
kubectl get secret -n kube-system gateway-tls
# Check Traefik logs
kubectl logs -n kube-system -l app.kubernetes.io/name=traefikThe Traefik deployment includes automatic healthchecks. To verify:
export KUBECONFIG=./volumes/kubeconfig/kubeconfig.yaml
# Check Traefik pod health
kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik
# Direct healthcheck (internal)
kubectl exec -n kube-system deploy/traefik -- wget -qO- http://localhost:8082/pingtron/
├── api/ # FastAPI backend
│ ├── app/ # Application code
│ ├── tests/ # API tests
│ ├── Dockerfile # Development Dockerfile
│ └── Dockerfile.prod # Production Dockerfile
├── portal/ # React frontend
│ ├── src/ # Source code
│ ├── Dockerfile # Development Dockerfile
│ └── Dockerfile.prod # Production Dockerfile
├── docker/ # Docker Compose configurations
│ ├── docker-compose.yaml # Development
│ └── docker-compose.prod.yaml # Production
├── scripts/ # Automation scripts
└── volumes/ # Persistent volumes (kubeconfig, tokens)
The development environment uses Dockerfiles optimized for local development:
- API:
api/Dockerfile- Development server with hot reload - Portal:
portal/Dockerfile- Development server with Vite HMR
Features:
- Hot reload enabled
- Volume mounts for live code changes
- Development dependencies included
- No optimization (faster builds)
Production builds use separate Dockerfiles with .prod suffix:
- API:
api/Dockerfile.prod- Optimized multi-stage build - Portal:
portal/Dockerfile.prod- Production build with Nginx
Features:
- Multi-stage builds (smaller images)
- Production optimizations
- No development dependencies
- Health checks configured
- Non-root user execution
Main environment variables can be configured in docker/docker-compose.yaml:
| Variable | Description | Default |
|---|---|---|
DB_HOST |
Database host | database |
DB_USER |
Database user | tron |
DB_PASSWORD |
Database password | tron |
DB_PORT |
Database port | 5432 |
DEBUG |
Enable debug mode | True |
SECRET_KEY |
API secret key | (see compose file) |
CORS_ORIGINS |
Allowed CORS origins | http://localhost:3000 |
# Via Make
make api-test
# Via Docker Compose
docker compose run --rm api-test
# Specific test file
docker compose run --rm api-test pytest tests/test_auth.py -v# Via Make
make portal-test
# Via Docker Compose
docker compose run --rm portal-test# API (Python - ruff)
cd api
uv tool run ruff check app/
uv tool run ruff format app/ --check
# Portal (TypeScript - ESLint)
cd portal
npm run lint
npx tsc --noEmitUsing Alembic for database migrations:
# Create a new migration
make api-migration
# Or manually
docker compose run --rm api alembic revision --autogenerate -m "description"
# Apply migrations
make api-migrate
# Or manually
docker compose run --rm api alembic upgrade head# Check database logs
docker compose logs database
# Verify database is healthy
docker compose exec database pg_isready -U tron -d api# Check API logs
docker compose logs api
# Run migrations manually
docker compose run --rm api-migrate# Check K3s logs
docker compose logs k3s-server
# Verify kubeconfig
cat ./volumes/kubeconfig/kubeconfig.yaml# Stop and remove all containers and volumes
docker compose down -v
# Start fresh
make startWhen ready to create a new release:
# Create and push tags for API and Portal
git tag -a api/v0.4.0 -m "Release API v0.4.0"
git tag -a portal/v0.4.0 -m "Release Portal v0.4.0"
git push origin api/v0.4.0 portal/v0.4.0This will:
- Build production images
- Push to GitHub Container Registry
- Create GitHub Releases
- NOT affect your local development environment