OpsCaptain Guide

Very straight forward. Log in, create an app, deploy your code and add custom domain and SSL.

Topics

Create your first app

Make sure you are logged into the dashboard and navigate to the Create new application page.

Enter a name for your app. Select the database if your app requires a database and then select the region where your application is to be deployed.

Click on the "Go Captain" button to create this application.

If you do not have a credit card on file, you will be required to pay for this application via paypal. To register a credit card, you can do so from the billing information page.

Create a new OpsCaptain app

Setting up environment variables

Locate your app under the Apps section on the dashboard. From the table, click on the name of your app to navigate to the app details section. Scroll down to the Environment Variables section and add your variables. Setting up environment variables

Connect to MongoDB from your app

You do not have to hardcode the database connection string. OpsCaptain by default sets the environemnt variable DATABASE_URI which provides you with the database connection string. If you still want to hardcode the connection string, you can find it under the app details section.

Example connecting to your database for Node.js:

var MongoClient = require('mongodb') // Connect to the db using the DATABASE_URI or MONGO_URL variables MongoClient.connect(process.env.DATABASE_URI, function(err, db) { if(!err) { console.log("We are connected"); } });
OpsCaptain database connection string.

Accepting connections and serving request

When you develop your app locally, typically it listens on port 3000 or some random port depending on the framework. On OpsCaptain you can retrieve the port to bind to using the environment variable PORT. This value is actually always 3000 on the OpsCaptain platform as well, but do not hardcode it and use the PORT environment variable instead.

Example listening for incomming connections for Node.js:

// Express.js example var app = express(); app.listen(process.env.PORT); // Listening using http: http.listen(process.env.PORT || 3000, function() {})

Deploying your code from GitHub, BitBucket or GitLab

Click on the name of your app from the dashboard to navigate to the App details section, select Git. If you have not yet configured a Git Provider account, simply select one under the provider section. After you authorize OpsCaptain to access your repositories, you can simply select the repository you wish to deploy, the branch and use the Go Captain button to deploy.

If you logged in with GitHub, Bitbucket or GitLab, your repositories should be displayed right away since you already have authorized OpsCaptain.

Deploy your app using Git.

Deploying your code by Uploading from the dashboard

Click on the name of your app from the dashboard to navigate to the App details section, select Upload Code. Select the the supported Language runtime and then select the zip or tar.gz archive file to upload to the server. Click on the Go Captain button to deploy.

Deploy your app by uploading your project folder.

Viewing app logs

Click on the name of your app from the dashboard to navigate to the App details section. Select App Logs to view your application logs.

Viewing HTTP logs

Click on the name of your app from the dashboard to navigate to the App details section. Select HTTP Logs to view your web request logs.

Configuring Force SSL

When you log into the OpsCaptain dashboard, you are first presented with the Apps & Databases section. Click on the name of your app. You will be navigated to the details section. Scroll to the Proxy settings section. Under Force SSL, click yes and then Save changes.

Force SSL on your project.

Setting custom domains

When you log into the OpsCaptain dashboard, you are first presented with the Apps & Databases section. Click on the name of your app. You will be navigated to the details section. Scroll to the Custom domains section and enter your domains. Specify each domain on a new line. Click on the Update domains

Still on the details page, you will notice your App URL. An example OpsCaptain App URL looks like this: [http://nodeapp-1.opscaptain.com] Create a CNAME record pointing to the host [nodeapp-1.opscaptain.com]. This will point your domain to your OpsCaptain app.

If you cannot create a CNAME, simply use the IP address provided on the App details page. You will have to scroll up from the Custom domains section to get it.

It is important to note the host [nodeapp-1.opscaptain.com] is derived from your App url, each of your apps will have a different host. Do not point any of your apps to the host [nodeapp-1.opscaptain.com]. 😃

Adding Let's Encrypt SSL certificates

When you log into the OpsCaptain dashboard, you are first presented with the Apps & Databases section. Click on the name of your app. You will be navigated to the details section. Scroll to the Let's encrypt SSL Domains section. Enter each of the domains you want to issue a certificate for in the textbox seperated with a new line. You have to ensure all the domains you have entered are currently reachable and pointing to your OpsCaptain app. If any of the domains are not configured correctly, the certificate issue process will fail. Click on the Create certificate button to create your SSL certificates.

Uploading custom SSL certificate

When you log into the OpsCaptain dashboard, you are first presented with the Apps & Databases section. Click on the name of your app. You will be navigated to the details section. Scroll to the custom certificate section and select your certificate files to be uploaded. You must select your private key file, the certificate itself and the intermediate certificate file if you have one.

Upload custom certificate.

Storing files on the server

If you need to store files uploaded by end users such as pictures and other assets, you can store them on the server at the path /oc-app-data. You can also retrieve this path from the environment variable FILE_STORAGE_DIR

When you store files in /oc-app-data, you can view them from the dashboard and even search and download them. To view your files, Log into the OpsCaptain dashboard. You are first presented with the Apps & Databases section. Click on the name of your app. You will be navigated to the details section. Click on Files storage to view your files.

Please note, if you store files at any path other than /oc-app-data, you will loose these files everytime you deploy code.

Storing files on the server.