CommandBox may also be used in production or continuous deployments, since it allows you to orchestrate your server environment. This eliminates dependency on hardware, and makes your CFML applications more portable, as a whole.
Since the startup of a CommandBox server allows you specify a host and server port, you can easily bind your server to a machine IP address and specify which port it should serve the application on. This allows you to proxy traffic to the application from IIS, Apache, or NGINX and even allows you to serve traffic directly on HTTP port 80 or 443, if you choose.
Container-based deployments are also supported, with official Docker Images and a buildpack for Heroku/Dokku.
CommandBox also provides an official Docker image, which allows you to leverage its capability to orchestrate live servers in multi-tier deployments.
Since, CommandBox allows you to configure your entire CFML engine environment from a single file in the root of your project, packaging or mounting your CFML application in to a running CommandBox image container allows you to stand up your application in Docker containers in a matter of seconds.
This section assumes you are using the Official Docker Image
By default, the directory /app in the container is mapped as Commandbox home. To deploy a new application, first pull the image:
docker pull ortussolutions/commandboxThen, from the root of your project, start with
docker run -p 8080:8080 -p 8443:8443 -v "/path/to/your/app:/app" ortussolutions/commandboxBy default the process ports of the container are 8080 (insecure) and 8443 (secure - if enabled in your server.json) so, once the container comes online, you may access your application via browser using the applicable port (which we explicitly exposed for external access in the run command above). You may also specify different port arguments in your run command to assign what is to be used in the container and exposed. This prevents conflicts with other instances in the Docker machine using those ports:
docker run -expose-list 80 443 -e "PORT=80" -e "SSL_PORT=443" -v "/path/to/your/app:/app" ortussolutions/commandboxTo create your own, customized Docker image, use our Dockerfile repository as the baseline to begin your customizations.
The CommandBox Docker image support the use of environmental variables for the configuration of your servers. Specifically, the image includes the cfconfig CommandBox module, which allows you to provide custom settings for your engine, including the admin password.
$PORT - The port which your server should start on. The default is 8080.
$SSL_PORT - If applicable, the ssl port used by your server The default is 8443.
$CFENGINE - Using the server.json syntax, allows you to specify the CFML engine for your container
$HEALTHCHECK_URI - Specifies the URI endpoint for container health checks. By default, this is set http://127.0.0.1:${PORT}/ at 1 minute intervals with 5 retries and a timeout of 30s
$cfconfig_[engine setting] - Any environment variable provided which includes the cfconfig_ prefix will be determined to be a cfconfig setting and the value after the prefix is presumed to be the setting name. The command cfconfig set ${settingName}=${value} will be run to populate your setting in to the $SERVER_HOME_DIRECTORY.
$cfconfigfile - A cfconfig-compatible JSON file may be provided with this environment variable. The file will be loaded and applied to your server. If an adminPassword key exists, it will be applied as the Server and Web context passwords for Lucee engines
$SERVER_HOME_DIRECTORY - When provided, a custom path to your server home directory will be assigned. By default, this path is set as /root/serverHome ( Note: You may also provide this variable in your app's customized server.json file )
Amazon Lightsail is a service that lets you spin up managed service quickly with a shell script.
https://aws.amazon.com/lightsail/
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-jre2. Install Commandbox
This is taken directly from (https://commandbox.ortusbooks.com/setup/installation)
#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 commandbox3. 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 /appPrivate 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 https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line. 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.
sudo git clone https://{username}:{access-token}@github.com/your/repo.git /app4. 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 install5. 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=80sudo 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"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!
There are many ways to install CommandBox in your Github actions. However, we have created the official Github Action package so you can install CommandBox easily: Setup CommandBox Action
The following are all the different input variables you can use on the action so you can setup CommandBox with ForgeBox API keys, default packages, specific versions and much more.
forgeboxAPIKey
string
---
If added to the action, we will seed it in CommandBox for you.
installSystemModules
boolean
false
If true then it will install: commandbox-cfconfig, commandbox-dotenv for you
install
string
---
If added, a comma-delmitted list of packages to install upon installation of the binary for you.
warmup
boolean
false
If true and no install inputs detected, it will run the box binary.
version
semver
latest
The CommandBox version to install, if not passed we use the latest stable.
Simple usage:
- name: Setup CommandBox
uses: Ortus-Solutions/[email protected]With Global Dependencies:
- name: Setup CommandBox
uses: Ortus-Solutions/[email protected]
with:
installSystemModules: trueWith Specific Dependencies:
- name: Setup CommandBox
uses: Ortus-Solutions/[email protected]
with:
install: commandbox-fusionreactorWith ForgeBox Token
- name: Setup CommandBox With ForgeBox Key
uses: Ortus-Solutions/[email protected]
with:
forgeboxAPIKey: my-tokenInstall a specific version of CommandBox
- name: Setup CommandBox With ForgeBox Key
uses: Ortus-Solutions/[email protected]
with:
version: 5.0.0

The Heroku buildpack for CommandBox will allow you to deploy your CFML applications directly to Heroku (or to Dokku hosts) using CommandBox to manage your CFML engine. It allows you to specify your custom server configuration settings using the CommandBox server API, avoiding additional script and configuration files during the Heroku deployment process.
Deploy a sample app:
Below are the configuration options for both Heroku and Dokku environments.
Create your heroku app:
heroku apps:create myapp.mydomain.comHeroku will return two URLS - the app domain ( you can configure a custom domain later ), and the heroku repository remote url which is configured to deploy your application.
Set up a new remote for this url:
git remote add heroku https://git.heroku.com/myapp.mydomain.com.gitSet your buildpack for Heroku with the command
heroku buildpacks:set https://github.com/ortus-solutions/heroku-buildpack-commandbox.gitCreate a file in the root of your project named .buildpacks and add the following to that file:
https://github.com/ortus-solutions/heroku-buildpack-commandbox.gitNow configure a new Git remote for your Dokku deployment ( Dokku will create the repo automatically if it doesn't exist ):
git remote add dokku https://dokku.mydomain.com/myapp.mydomain.com.gitBoth Heroku and Dokku use a git push to the repository to trigger deployment. By default the master branch is the only branch triggered for deployment with a push. A simple push the repository triggers the deployment (using the remote name you set in configuration):
git push heroku masterYou may override this by specifying a branch in your push to act as master (e.g. - deploying to a staging instance):
git push heroku yourbranch:masterOnce deployment is returned as successful, you may receive NGINX 502 errors for up to 60 seconds as the CommandBox server starts up for the first time.
For zero-downtime deployments on Dokku, create a CHECKS file in the root of your project, which will ensure that your application is up and running before bringing the container online during redeployment.
For implementing a zero-downtime deployment strategy on Heroku, you can customize the postdeploy script in your app.json file or use Heroku's preboot feature
You may run additional commands on your server environment or enter a terminal to connect to your dyno by simply typing heroko run bash from the root directory of your project.
Your heap size settings will need to be configured according to the dyno size ( Heroku ) or available memory of the Dokku instance. By default, Commandbox uses a heap size of 512MB, which is larger than the free/hobby tier for Heroku. A heap size setting larger than that allocated to the dyno will cause a Commandbox startup failure.
See Heroku's environmental notes for Java heap sizes to determine your available heap size upon deployment.
To set the heap size to 300MB, for example, simply run box server set jvm.heapsize=300. This will save the setting to your server.json file and will persist that value to your deployed application.



