CommandBox : CLI, Package Manager, REPL & More
5.1.0
5.1.0
  • Introduction
  • About This Book
  • Authors
  • Overview
  • Getting Started Guide
  • Setup
    • Requirements
    • Download
    • Installation
    • Light and Thin Binaries
    • Non-Oracle JREs
    • Upgrading
    • Common Errors
  • Usage
    • Execution
      • Recipes
      • CFML Files
        • Using a DB in CFML scripts
      • OS Binaries
      • CFML Functions
      • Exit Codes
    • Commands
    • Parameters
      • Escaping Special Characters
      • File Paths
      • Globbing Patterns
      • Piping into Commands
      • Expressions
    • Command Help
    • Environment Variables
    • System Settings
    • Ad-hoc Command Aliases
    • Default Command Parameters
    • REPL
    • Tab Completion
    • Interactive Shell Features
    • forEach Command
    • Auto Update Checks
    • Bullet Train Prompt
    • 256 Color Support
    • A Little Fun
  • IDE Integrations
    • Sublime Text
    • Visual Studio Code
  • Config Settings
    • Module Settings
    • Proxy Settings
    • Endpoint Settings
    • Server Settings
    • Misc Settings
  • Embedded Server
    • Multi-Engine Support
    • Start HTML Server
    • Offline Server Starts
    • Debugging Server Starts
    • Server Processes
    • Manage Servers
    • FusionReactor
    • Server Logs
    • Configuring Your Server
      • JVM Args
      • Server Port and Host
      • URL Rewrites
      • Aliases
      • Custom Error Pages
      • Welcome Files
      • Basic Authentication
      • Custom Java Version
      • Adding Custom Libs
      • GZip Compression
      • REST Servlet
      • Performance Tuning
      • Undertow Options
      • Custom Tray Menus
    • External Web Server
    • Starting as a Service
    • Server.json
      • Working with server.json
      • Packaging Your Server
      • Using Multiple server.json Files
  • Package Management
    • Installing Packages
      • Installation Path
      • Installation Options
      • Advanced Installation
    • Private Packages
    • System Modules
    • Code Endpoints
      • ForgeBox
      • HTTP(S)
      • File
      • Folder
      • Git
      • Java
      • S3
      • CFLib
      • Jar (via HTTP)
      • Lex (via HTTP)
      • Gist
    • Package Scripts
    • Dependencies
    • Semantic Versioning
    • Updating Packages
    • Creating Packages
      • Editing Package Properties
      • Publishing Lucee Extensions to ForgeBox
    • Artifacts
    • Box.json
      • Basic Package Data
      • Extended Package Data
      • Package URLs
      • Installation
      • Embedded Server
      • Dependencies
      • TestBox
    • Managing Version
  • Task Runners
    • Task Anatomy
    • Task Target Dependencies
    • Passing Parameters
    • Using Parameters
    • Task Output
    • Task Interactivity
    • Shell Integration
    • Downloading Files
    • Running Other Commands
    • Error Handling
    • Hitting Your Database
    • Interactive Jobs
    • Watchers
    • Property Files
    • Running other Tasks
    • Loading Ad hoc Jars
    • Loading Ad-hoc Modules
    • Cancel Long Tasks
    • Progress Bar
  • Helpful Commands
    • Token Replacements
    • Checksums
    • Code Quality Tools
  • Deploying CommandBox
    • Docker
    • Heroku
    • Amazon Lightsail
  • TestBox Integration
    • Test Runner
    • Test Watcher
  • Developing For CommandBox
    • Modules
      • Installation and Locations
      • Configuration
        • Public Properties
        • Configure() Method
        • Lifecycle Methods
      • Conventions
      • User Settings
      • Linking Modules
    • Commands
      • Aliases
      • Using Parameters
        • Using File Globs
        • Dynamic Parameters
      • Command Output
      • Tab Completion & Help
      • Interactivity
      • Watchers
      • Shell integration
      • Running Other Commands
      • Error handling
      • Watchers
      • Loading Ad hoc Jars
    • Interceptors
      • Core Interception Points
        • CLI Lifecycle
        • Command Execution Lifecycle
        • Module Lifecycle
        • Server Lifecycle
        • Error Handling
        • Package Lifecycle
      • Custom Interception Points
    • Injection DSL
    • Example Project
    • FusionReactor for the CLI
  • ForgeBox Enterprise
    • Introduction
    • Storage
    • Commands
      • List
      • Register
      • Login
      • Set Default
      • Remove
    • Usage
Powered by GitBook
On this page
  • Setting up a Server
  • Final script
  • That's it

Was this helpful?

Edit on Git
Export as PDF
  1. Deploying CommandBox

Amazon Lightsail

PreviousHerokuNextTestBox Integration

Last updated 5 years ago

Was this helpful?

Amazon Lightsail is a service that lets you spin up managed service quickly with a shell script.

Setting up a Server

First login to your Amazon Lightsail account and create an instance

Instance Settings

These are the insance settings that are working. Your mileage may vary for something not indicated in this list.

  • Select OS Only

  • Ubuntu 18.04

  • Add Launch Script (script below)

  • Select 1GB - $5 plan.

  • Assign a name to your instance under "Identify Your Instance"

That's basically it for settings!

Now before you click create, you'll need the following template to get your site working on Amazon Lightsail. You only get one shot at this when it initializes. You can't do this later.

Commandbox Template

Full script at the end but here is the play by play

1. Install Java

Commandbox needs Java to run

# They try to ship out Ubuntu as light as possible so you'll want to run this first to get all the latest repo information
sudo apt-get update
# install java openJDK 8 for commandbox
yes | sudo apt-get install openjdk-8-jre

2. Install Commandbox

#taken straight from ortus docs commandbox install
curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo apt-key add -
echo "deb http://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a /etc/apt/sources.list.d/commandbox.list
sudo apt-get update && sudo apt-get install commandbox

3. Download your code/repo

In this template, we are using Ortus' awesome Github repo with Elixir and Vue.js. There are other ways like copying over from a local file with SSH or use a disk that you created in Amazon Lightsail that will persist even if the instance is delete. Notice here that we saved it to the /app directory. Note that for later when you run your app, to navigate to it.

sudo git clone https://github.com/coldbox-templates/elixir-vuejs.git /app
sudo git clone https://{username}:{access-token}@github.com/your/repo.git /app

4. Install any dependencies

For example you can run your box dependencies or if you are using webpack, this would be the time to get all that compiled.

cd /app && sudo box install

5. Run the server

In here we start the server in the /app directory. We set the host to 0.0.0.0 so that it listens on any interface/hostname assigned to it. Also, we define the port 80 so that it's not some random port generated by commandbox. Long story short, when this thing runs, we know all we need to do is hit the IP address that Amazon Lightsail assigned to it.

cd /app && sudo box start --debug host=0.0.0.0 port=80

Final script

sudo apt-get update
#install java openJDK 8 for commandbox. For openJDK 11,you can use apt-get install default-jre
yes | sudo apt-get install openjdk-8-jre

#taken straight from ortus docs commandbox install
curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo apt-key add -
echo "deb http://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a /etc/apt/sources.list.d/commandbox.list
sudo apt-get update && sudo apt-get install commandbox

#might need this later for webpack
yes | sudo apt install npm
#clone your repo to the /app directory, just like Ortus does
sudo git clone https://github.com/coldbox-templates/elixir-vuejs.git /app
#For Private repo format
#sudo git clone https://{username}:{access-token}@github.com/your/repo.git /app

#start server and expose it to the world
cd /app && sudo box install
sudo box start --debug host=0.0.0.0 port=80

#Note: For openJDK 11 to work, you will need to add a JVM arg to prevent this issue https://luceeserver.atlassian.net/browse/LDEV-1138
#sudo box start --debug host=0.0.0.0 port=80 JVMArgs="-Djdk.attach.allowAttachSelf=true"

That's it

All you have to do is create your instance. It will boot up and when it is finally running, you should have a Public IP address assigned to it...But don't be in to big of a hurry. With these settings, it takes about 4 minutes and 30 seconds before Commandbox is serving something. Wait for it and enjoy!

This is taken directly from ()

Private Repo If you want to automate a private repo, one way you can do it is to use an access token. The procedure is here . You can create an an access token for downloading private repos without exposing your account password. Fair warning, it's not a perfect solution because as of 08/27/19, they still don't have a read-only permission for private repos.

https://commandbox.ortusbooks.com/setup/installation
https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
https://aws.amazon.com/lightsail/
Amazon Lightsail