Skip to content

feat: Add install-fleetbase Command#3

Open
roncodes wants to merge 1 commit intomainfrom
feature/install-fleetbase-command
Open

feat: Add install-fleetbase Command#3
roncodes wants to merge 1 commit intomainfrom
feature/install-fleetbase-command

Conversation

@roncodes
Copy link
Member

Overview

This PR adds a new install-fleetbase command to the Fleetbase CLI, making it easier for users to install Fleetbase using Docker without having to manually run bash scripts.

Motivation

Currently, users need to:

  1. Clone the Fleetbase repository
  2. Navigate to the scripts directory
  3. Run ./docker-install.sh
  4. Answer prompts in the terminal

This PR simplifies the process by integrating installation directly into the CLI, providing a more consistent and user-friendly experience.

Features

Interactive Mode

flb install-fleetbase

Prompts the user for:

  • Host/IP address (default: localhost)
  • Environment (development or production)
  • Installation directory (default: current directory)

Non-Interactive Mode

flb install-fleetbase --host localhost --environment development --directory ./fleetbase

All parameters can be provided via command-line options for automation and scripting.

What It Does

  1. Validates installation directory - Checks for docker-compose.yml
  2. Generates APP_KEY - Uses Node.js crypto module (same as bash script)
  3. Creates docker-compose.override.yml - With environment-specific configuration
  4. Creates console/fleetbase.config.json - With API and SocketCluster settings
  5. Starts Docker containers - Runs docker compose up -d
  6. Waits for database - 15-second wait for database readiness
  7. Runs deployment - Executes deploy.sh inside application container
  8. Displays access URLs - Shows API and Console URLs with default credentials

Command Options

Option Description Default
--host <host> Host or IP address to bind to localhost
--environment <env> Environment (development/production) development
--directory <dir> Installation directory Current directory

Implementation Details

Configuration Logic

Development Environment:

  • HTTP (not HTTPS)
  • APP_DEBUG=true
  • SOCKETCLUSTER_SECURE=false

Production Environment:

  • HTTPS
  • APP_DEBUG=false
  • SOCKETCLUSTER_SECURE=true

Error Handling

  • Validates directory exists
  • Checks for docker-compose.yml
  • Provides helpful error messages
  • Suggests manual steps if deployment fails

Cross-Platform Compatibility

Unlike the bash script (docker-install.sh), this Node.js implementation works on:

  • ✅ Linux
  • ✅ macOS
  • ✅ Windows (with Docker Desktop)

Example Output

🚀 Fleetbase Installation

? Enter host or IP address to bind to: › localhost
? Choose environment: › Development
? Installation directory: › /home/user/fleetbase

📋 Configuration:
   Host: localhost
   Environment: development
   Directory: /home/user/fleetbase
   HTTPS: false

⏳ Generating APP_KEY...
✔  APP_KEY generated
⏳ Creating docker-compose.override.yml...
✔  docker-compose.override.yml created
⏳ Creating console/fleetbase.config.json...
✔  console/fleetbase.config.json created

⏳ Starting Fleetbase containers...
   This may take a few minutes on first run...

✔  Containers started

⏳ Waiting for database to be ready...
✔  Database should be ready

⏳ Running deployment script...
✔  Deployment complete

🏁 Fleetbase is up!
   API     → http://localhost:8000
   Console → http://localhost:4200

ℹ️  Default credentials:
   Email: admin@fleetbase.io
   Password: password

Benefits

Better UX - Integrated into CLI workflow
Cross-platform - Works on Windows, macOS, Linux
Automation-friendly - Supports non-interactive mode
Better error handling - Clear validation and error messages
Consistent - Uses same CLI patterns as other commands
Documented - Built-in help via flb install-fleetbase --help

Testing Checklist

  • Test interactive mode with default values
  • Test interactive mode with custom values
  • Test non-interactive mode with all options
  • Test with non-existent directory (should fail gracefully)
  • Test with directory missing docker-compose.yml (should fail gracefully)
  • Test development environment configuration
  • Test production environment configuration
  • Verify generated APP_KEY format
  • Verify docker-compose.override.yml content
  • Verify console/fleetbase.config.json content
  • Test on Linux
  • Test on macOS
  • Test on Windows (if applicable)

Related Work

This command complements the existing installation documentation and provides an alternative to the bash script for users who prefer CLI-based workflows.

Future Enhancements

Potential future improvements:

  • Add --skip-deploy flag to skip automatic deployment
  • Add --pull flag to pull latest images before starting
  • Add health check polling instead of fixed wait time
  • Add --verbose flag for detailed Docker output
  • Support for custom Docker Compose files

This commit adds a new 'install-fleetbase' command to the CLI that automates
the Fleetbase Docker installation process.

## Features

- Interactive prompts for host, environment, and directory
- Command-line options for non-interactive usage
- Automatic APP_KEY generation using crypto
- Creates docker-compose.override.yml with environment configuration
- Creates console/fleetbase.config.json with API and SocketCluster settings
- Starts Docker containers and waits for database readiness
- Runs deployment script automatically
- Provides clear status messages and error handling

## Usage

Interactive mode:
  flb install-fleetbase

Non-interactive mode:
  flb install-fleetbase --host localhost --environment development --directory ./fleetbase

## Options

--host <host>              Host or IP address to bind to (default: localhost)
--environment <env>        Environment: development or production (default: development)
--directory <directory>    Installation directory (default: current directory)

## Implementation

The command replicates the functionality of scripts/docker-install.sh but
provides a better user experience through:
- Interactive prompts with validation
- Clear progress indicators
- Better error messages
- Cross-platform compatibility (Node.js vs Bash)
- Integration with the CLI ecosystem

## Benefits

- Easier onboarding for new users
- Consistent installation experience
- No need to navigate to scripts directory
- Better error handling and validation
- Works on Windows, macOS, and Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant