Getting Started
Installation Guide
Step-by-step instructions to install and set up Nanostack
Installation Guide
This guide will help you install and configure Nanostack for your development environment.
Prerequisites
Before installing Nanostack, ensure you have:
- Go 1.21+ installed
- PostgreSQL 14+ running
- Redis (optional, for caching)
- Docker (optional, for containerized deployment)
Method 1: Docker Compose (Recommended)
The fastest way to get started with Nanostack is using Docker Compose:
# Clone the repository
git clone https://github.com/nanostack/backend
cd nanostack
# Copy environment file
cp .env.example .env
# Start all services
docker-compose up -d
# Check if services are running
docker-compose ps
This will start:
- Nanostack API server on port 8080
- PostgreSQL database on port 5432
- Redis cache on port 6379
- Adminer (database UI) on port 8081
Method 2: Local Development
For local development with more control:
1. Install Dependencies
# Clone the repository
git clone https://github.com/nanostack/backend
cd nanostack
# Install Go dependencies
go mod download
# Install development tools
go install github.com/air-verse/air@latest
go install github.com/golang-migrate/migrate/v4/cmd/migrate@latest
2. Set Up Database
# Create database
createdb nanostack_dev
# Run migrations
migrate -path migrations -database "postgres://localhost/nanostack_dev?sslmode=disable" up
3. Configure Environment
# Copy environment file
cp .env.example .env
# Edit configuration
nano .env
Key environment variables:
DATABASE_URL=postgres://localhost/nanostack_dev?sslmode=disable
JWT_SECRET=your-super-secret-key-change-this
REDIS_URL=redis://localhost:6379
PORT=8080
4. Start Development Server
# Using Air for hot reload
air
# Or run directly
go run main.go
Method 3: Production Deployment
Kubernetes
# Apply Kubernetes manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get pods -l app=nanostack
Docker
# Build production image
docker build -t nanostack:latest .
# Run with environment variables
docker run -p 8080:8080 \
-e DATABASE_URL=postgres://... \
-e JWT_SECRET=... \
nanostack:latest
Verification
After installation, verify Nanostack is running:
# Check health endpoint
curl http://localhost:8080/health
# Expected response
{"status":"ok","database":"connected","version":"1.0.0"}
Visit http://localhost:8080/docs
to see the interactive API documentation.
Troubleshooting
Common Issues
Database Connection Failed
# Check PostgreSQL is running
pg_isready
# Verify connection string
psql $DATABASE_URL
Port Already in Use
# Find process using port 8080
lsof -i :8080
# Kill the process
kill -9 <PID>
Migration Errors
# Reset database
dropdb nanostack_dev
createdb nanostack_dev
# Run migrations again
migrate -path migrations -database $DATABASE_URL up
Next Steps
Now that Nanostack is installed:
Getting Help
If you encounter issues:
- Check our GitHub Issues
- Join our Discord
- Email [email protected]