nexlayer-cli

command module
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 1 Imported by: 0

README ΒΆ

Nexlayer CLI

πŸš€ Deploy and manage full-stack applications in minutes with Nexlayer CLI. Built for developers who value simplicity without sacrificing power.

Quick Start (30 seconds)

# 1. Install the CLI
go install github.com/Nexlayer/nexlayer-cli@latest

# 2. Start the interactive wizard
nexlayer wizard

That's it! The wizard will guide you through deployment setup. Want more control? Check out the manual setup below.

Requirements

  • Go version 1.21 or later
  • Git (for version control)
  • Docker (for container builds)

Installation

go install github.com/Nexlayer/nexlayer-cli@latest

Make sure your $GOPATH/bin is in your system PATH to access the CLI globally.

Common Commands

# Start the interactive wizard (recommended for first-time users)
nexlayer wizard

# Initialize a new project
nexlayer init

# Deploy your application
nexlayer deploy my-app

# Check deployment status
nexlayer status my-app

# View logs
nexlayer logs my-app

# Scale your application
nexlayer scale my-app --replicas 3

Real-World Examples

1. CI/CD Pipeline Integration
# .github/workflows/deploy.yml
name: Deploy with Nexlayer
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Nexlayer CLI
        run: go install github.com/Nexlayer/nexlayer-cli@latest
      - name: Deploy to Production
        run: |
          nexlayer deploy my-app \
            --env production \
            --auto-approve
        env:
          NEXLAYER_AUTH_TOKEN: ${{ secrets.NEXLAYER_AUTH_TOKEN }}
2. Multi-Environment Setup
# Development deployment
nexlayer deploy my-app --env staging

# Production deployment with increased resources
nexlayer deploy my-app --env production \
  --replicas 3 \
  --cpu 2 \
  --memory 4Gi
3. Advanced Configuration
# nexlayer.yaml
version: '1'
app:
  name: my-awesome-app
  template: node-typescript
  env:
    NODE_ENV: production
    API_URL: https://api.example.com
  resources:
    cpu: 1
    memory: 2Gi
  scaling:
    min: 2
    max: 5
    targetCPU: 70

Environment Setup

The CLI requires only one environment variable:

NEXLAYER_AUTH_TOKEN="your_auth_token"    # Your authentication token from https://app.nexlayer.io/settings/tokens

This token is used to authenticate your CLI requests with the Nexlayer API. You can get your token by:

  1. Logging into your Nexlayer account
  2. Going to Settings β†’ API Tokens
  3. Creating a new token with appropriate permissions

For different environments:

  • Use --env staging (default) to deploy to https://app.staging.nexlayer.io
  • Use --env production to deploy to https://app.nexlayer.io

Security Best Practices

Authentication Token Security
  1. Never commit tokens to version control

    • Store tokens in environment variables
    • Use secure secret management in CI/CD pipelines
    • Consider using tools like HashiCorp Vault or AWS Secrets Manager
  2. Token Best Practices

    • Rotate tokens regularly
    • Use tokens with minimal required permissions
    • One token per environment/purpose
    • Revoke tokens immediately if exposed
  3. Local Development

    • Use .env files (not committed to git)
    • Different tokens for different environments
    # .env.development
    NEXLAYER_AUTH_TOKEN=dev_token
    NEXLAYER_STAGING_API_URL=http://localhost:8080
    
Secure CI/CD Integration
# GitHub Actions example with secure token handling
name: Deploy with Nexlayer
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Nexlayer CLI
        run: go install github.com/Nexlayer/nexlayer-cli@latest
      - name: Deploy to Production
        env:
          # Use GitHub's secret management
          NEXLAYER_AUTH_TOKEN: ${{ secrets.NEXLAYER_AUTH_TOKEN }}
        run: nexlayer deploy my-app --env production
File Security

Ensure these files are in your .gitignore:

  • .env and .env.* files
  • *.pem, *.key, *.cert files
  • Local development configurations
  • Build artifacts and logs

Troubleshooting

Common Error Messages
  1. Authentication Error

    ❌ Authentication required
    πŸ’‘ Quick fixes:
       β€’ Make sure NEXLAYER_AUTH_TOKEN is set in your environment
       β€’ Run 'nexlayer auth login' to authenticate
       β€’ Visit https://app.nexlayer.io/settings/tokens to generate a token
    
  2. YAML Validation Error

    ❌ Invalid template YAML
    πŸ’‘ Quick fixes:
       β€’ Check the YAML syntax
       β€’ Ensure all required fields are present
       β€’ Run 'nexlayer validate' to check template structure
    
  3. Deployment Error

    ❌ Deployment failed
    πŸ’‘ Quick fixes:
       β€’ Check your network connection
       β€’ Verify your authentication token
       β€’ Run with --debug flag for more information
    
Debug Mode

Add the --debug flag to any command for detailed output:

nexlayer deploy my-app --debug

Best Practices

  1. Version Control: Always commit your nexlayer.yaml configuration
  2. Environment Variables: Use .env files for local development
  3. CI/CD: Use environment-specific configurations
  4. Monitoring: Regularly check nexlayer status and nexlayer logs

Support

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
examples
pkg
ai
api
tui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL