@stacksolo/cli
v0.1.14
Published
CLI for StackSolo - deploy GCP infrastructure from the command line
Maintainers
Readme
@stacksolo/cli
A command-line tool for deploying apps to Google Cloud. Designed for solo developers who want to ship fast without managing complex cloud configurations.
What does it do?
StackSolo takes your code and a simple config file, then handles all the cloud setup for you:
- Creates Cloud Functions for your backend
- Sets up load balancers to route traffic
- Hosts your frontend on Cloud Storage
- Manages databases and caches
- Handles all the networking automatically
You focus on writing code. StackSolo handles the infrastructure.
Installation
npm install -g @stacksolo/cliPrerequisites
Before using StackSolo, you need:
Node.js 18 or newer
node --version # Should show v18.x.x or higherTerraform CLI - This is the tool that actually creates cloud resources
# macOS brew install terraform # Or download from: https://developer.hashicorp.com/terraform/installGoogle Cloud CLI - For authenticating with GCP
# macOS brew install google-cloud-sdk # Or download from: https://cloud.google.com/sdk/docs/installAuthenticate with Google Cloud
gcloud auth login gcloud auth application-default login
Quick Start
Step 1: Initialize a new project
stacksolo initThis creates a .stacksolo/stacksolo.config.json file with your project settings.
Step 2: Add your code
Create a function at functions/api/index.ts:
import * as functions from '@google-cloud/functions-framework';
functions.http('api', (req, res) => {
res.json({ message: 'Hello from StackSolo!' });
});Step 3: Deploy to GCP
stacksolo deployThat's it! Your API is now live on Google Cloud.
Commands
stacksolo init
Creates a new StackSolo project in the current directory.
What it does:
- Asks you some questions about your project
- Creates a
.stacksolo/stacksolo.config.jsonfile - Registers the project in your global registry
Example:
cd my-project
stacksolo initstacksolo deploy
Deploys your infrastructure to Google Cloud.
What it does:
- Reads your config file
- Generates Terraform code
- Runs Terraform to create resources
- Shows you the URLs when done
Example:
stacksolo deployFlags:
--dry-run- Show what would be deployed without actually deploying
stacksolo destroy
Deletes all resources created by StackSolo.
What it does:
- Runs Terraform destroy
- Removes all cloud resources
- Cleans up local state
Example:
stacksolo destroyWarning: This permanently deletes your infrastructure. Any data stored in databases or storage buckets will be lost.
stacksolo status
Shows the current state of your deployment.
What it does:
- Reads the Terraform state
- Shows what resources exist
- Shows URLs for your services
Example:
stacksolo statusstacksolo list
Lists all StackSolo projects on your computer.
What it does:
- Reads from your global registry (
~/.stacksolo/registry.db) - Shows project names and paths
Example:
# List all projects
stacksolo list
# Show details for a specific project
stacksolo list my-appstacksolo dev
Starts a local development environment using Kubernetes.
What it does:
- Generates Kubernetes manifests from your config
- Starts a local K8s cluster (using Docker Desktop or minikube)
- Runs Firebase emulators for Firestore, Auth, and Pub/Sub
- Sets up port forwarding so you can access your services
Example:
stacksolo devFlags:
--no-emulators- Skip starting Firebase emulators--health- Check the health of running services--ports- Show port forwarding status--restart [service]- Restart a specific service or all services--service-names- List available service names
stacksolo scaffold
Generates starter code and local dev files from your config.
What it does:
- Creates function/container boilerplate
- Generates
.env.localwith environment variables - Creates
lib/env.tsfor type-safe env access - Sets up Kubernetes manifests for local dev
Example:
stacksolo scaffoldProject Configuration
StackSolo uses a JSON config file at .stacksolo/stacksolo.config.json. Here's a simple example:
{
"project": {
"name": "my-app",
"gcpProjectId": "my-gcp-project",
"region": "us-central1"
},
"networks": [{
"name": "main",
"functions": [{
"name": "api",
"runtime": "nodejs20",
"entryPoint": "api"
}],
"loadBalancer": {
"name": "gateway",
"routes": [
{ "path": "/*", "functionName": "api" }
]
}
}]
}What each part means:
- project.name - A name for your project (used in resource naming)
- project.gcpProjectId - Your Google Cloud project ID
- project.region - Where to deploy (e.g.,
us-central1,europe-west1) - networks - Groups of related resources
- functions - Serverless functions (your backend code)
- loadBalancer - Routes traffic to your functions
For detailed config options, see the GCP CDKTF Plugin docs.
Supported Resources
StackSolo can create these Google Cloud resources:
| Resource | What it's for | |----------|---------------| | Cloud Functions (Gen2) | Serverless backend code that scales automatically | | Cloud Run | Containerized apps with more control than Functions | | Cloud Storage | File storage (also hosts static websites) | | Pub/Sub | Message queues for async processing | | VPC Networks | Private networking between your services | | Load Balancers | Route traffic to multiple backends | | Firestore | NoSQL database |
Local Development
StackSolo includes a local Kubernetes environment that mirrors production:
stacksolo devThis creates a local K8s cluster with:
- Firebase emulators - Fake versions of Firestore, Auth, and Pub/Sub
- Hot-reloading - Your code updates automatically when you save
- Service mesh - Services can call each other just like in production
- Environment variables - Same env vars as production
Why Kubernetes locally?
Using K8s locally means your dev environment works exactly like production. No more "it works on my machine" problems.
Runtime Package
When writing your function code, use the @stacksolo/runtime package for environment detection and service calls:
npm install @stacksolo/runtimeimport { env, firestore, services } from '@stacksolo/runtime';
// Check if running locally or in production
if (env.isLocal) {
console.log('Running with emulators');
}
// Auto-configured Firestore client (uses emulator locally)
const db = firestore();
const users = await db.collection('users').get();
// Call another service in your stack
const response = await services.call('api', '/users');See the Runtime package docs for more details.
Global Project Registry
StackSolo keeps track of all your projects in a local database at ~/.stacksolo/registry.db. This lets you:
- Switch between projects easily
- See all your StackSolo projects in one place
- Access project info from any directory
# List all projects
stacksolo list
# Register the current directory as a project
stacksolo register
# View details about a specific project
stacksolo list my-appTypical Workflow
Here's how most developers use StackSolo:
Start a new project:
mkdir my-app && cd my-app stacksolo initWrite your code:
# Create your function mkdir -p functions/api # ... write code ...Develop locally:
stacksolo scaffold # Generate boilerplate stacksolo dev # Start local environmentDeploy to production:
stacksolo deployCheck status:
stacksolo statusMake changes and redeploy:
# ... edit code ... stacksolo deploy
Links
License
MIT
