Deployment
Deploying Kthulu applications to Cloud and Docker.
Kthulu applications are designed with the "One-Bin" philosophy, simplifying deployment by compiling everything into a single binary. The frontend assets are embedded directly into the Go binary.
Building for Production
To build your application as a standalone binary:
go build -tags prod -o app cmd/server/main.go
This binary contains your API server and your static frontend files (served from the binary itself).
Docker Deployment
Kthulu provides robust Docker support out of the box.
Single Container (Recommended)
The project includes a multi-stage Dockerfile.fullstack that builds the frontend assets and the backend (using Go), producing a minimal scratch-based image.
To build and run:
# Build the image
docker build -f Dockerfile.fullstack -t my-app .
# Run the container
docker run -p 8080:8080 -e DOMAIN=example.com my-app
This image is highly optimized (typically < 20MB compressed) and includes:
- AutoTLS (Let's Encrypt) when
DOMAINis set. - Embedded frontend assets.
- Timezone data and CA certificates.
Docker Compose
For development or deployments requiring a separate database, use the provided docker-compose.yml:
docker-compose up -d
This spins up:
api: The Go backend.db: A PostgreSQL instance.
Cloud Deployment (CLI)
The kthulu deploy command automates the generation of Kubernetes manifests and Docker builds.
kthulu deploy --cloud=kubernetes --namespace=production
This command will:
- Analyze your project structure.
- Generate a
Dockerfileif one is missing. - Build the Docker image.
- Generate Kubernetes manifests (
deployment.yaml,service.yaml,hpa.yaml) indeployments/kubernetes/. - Apply them to your cluster using
kubectl.
Environment Variables
Common configuration variables:
PORT: HTTP port (default: 8080).DOMAIN: Domain name for AutoTLS (e.g.,myapp.com).DATABASE_URL: Connection string for the database (PostgreSQL/SQLite).ENVIRONMENT:productionordevelopment.JWT_SECRET: Secret for signing auth tokens.