joshstrange / caprover-cli

Command Line Interface for https://github.com/caprover/caprover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CapRover CLI

Command Line Interface for CapRover. Fore more information see www.CapRover.com

CapRover is a modern automated app deployment & web server manager.

  • Deploy apps in your own space
  • Secure your services over HTTPS for FREE
  • Scale in seconds
  • Focus on your apps! Not the bells and whistles just to run your apps!

Getting started!

This guide assumes that you have installed CapRover on a linux server.

You can use this CLI tool to deploy your apps. Before anything, install the CLI tool using npm:

npm install -g caprover

Server Setup

The very first thing you need to do is to setup your CapRover server. You can either do this by visiting HTTP://IP_ADDRESS_OF_SERVER:3000 in your browser, or the recommended way which is the command line tool. Simple run

caprover serversetup

Follow the steps as instructed, enter IP address of server. Enter the root domain to be used with this CapRover instance. If you don't know what CapRover root domain is, please visit www.CapRover.com for documentation. This is a very crucial step. After that, you'll be asked to enter your email address. This should be a valid email address as it will be used in your SSL certificate. After HTTPS is enabled, you'll be asked to change your password. And... Your are done! Go to Deploy section below to read more about app deployment.

For automation purposes, you can create a temporary config file like:

{
  "machineName": "my-machine-123-123-123-123",
  "ipAddress": "123.123.123.123",
  "newPassword": "rAnDoMpAsSwOrD",
  "rootDomain": "root.domain.com",
  "emailForHttps": "email@gmail.com",
  "currentPassword": "captain42"
}

Then run:

caprover login -c /path/to/temp-config.json 

Note: you can also use either YAML or JSON.

Login

If you've done the "Server Setup" process through the command line. You can skip "Login" step because "server setup" automatically logs you in as the last step of setup.

The very first thing you need to do is to login to your CapRover server. It is recommended that at this point you have already set up your HTTPS. Login over insecure, plain HTTP is not recommended.

To log in to server, simply run the following line and answer the questions.

caprover login

If operation finishes successfully, you will be prompted with a success message.

NOTE: You can be logged in to several CapRover servers at the same time. This is particularly useful if you have separate staging and production servers.

For automation purposes, you can create a temporary config file like:

{
  "hasRootHttps": "true",
  "caproverPassword": "captain42",
  "caproverUrl": "captain.root.domain.com",
  "caproverName": "testing-1"
}

Then run:

caprover login -c /path/to/temp-config.json 

Note: you can also use either YAML or JSON.

Deploy

In order to deploy your application, you first need to create captain-definition file and place it in the root of your project folder. In case of a nodejs application, this would sit in the same folder as your package.json.

Captain definition file for a nodejs application is:

 {
  "schemaVersion" :2 ,
  "templateId" :"node/8.7.0"
 }

See https://caprover.com/docs/captain-definition-file.html for more details on Captain Definition file.

After making sure that this file exists, run the following command and answers questions:

caprover deploy

You will then see your application being uploaded, after that, your application getting built. Note that the build process takes multiple minutes, please be patient!

You can also deploy directly with one command:

caprover deploy -h https://captain.root.domain.com -a app-name -p password -b branchName

This can be useful if you want to integrate CI/CD pipeline.

List logged in servers

To see a list of servers you are currently logged in to, run the following line:

caprover list

Logout

Run the following command:

caprover logout

About

Command Line Interface for https://github.com/caprover/caprover


Languages

Language:TypeScript 99.4%Language:Dockerfile 0.6%