Getting Started

1. Before you begin

The Ops CLI has the following dependencies:

Please install these if you haven't already.

Note: The CLI is presently compatible with only Mac and Linux.

2. Install the ops CLI

Open your terminal and paste the following at the prompt:

$ npm install -g

To check it was installed properly, run the CLI without any arguments:

$ ops

If this outputs a list of commands, you're good to go!

2. Sign in

Before you can find ops to run, you need to sign up for an account. This is done via the command-line:

$ ops account:signup

Once your account is created successfully, sign yourself in:

$ ops account:signin

At any time, you can confirm who is logged in by running:

$ ops whoami

Great, now let's run our first op.

3. Run an op

First let's see what public ops are available:

$ ops search

From the list of options, choose the temperature op. Then, run it like this:

$ ops run temperature

Congrats, you ran your first op! Let's try passing a city flag:

$ ops run temperature -c Halifax

Now that you have a taste of what ops can do, let's build our own.

4. Create a new op

Run this to generate a new op:

$ ops init

Name your op my-first-op when prompted, or bypass the prompts by passing these flags:

$ ops init --name my-first-op --description "best op ever"

This will create a new directory called my-first-op containing all the op code.

Let's go ahead and run our starter op and see what we get out of the box:

$ ops run my-first-op

This will build the op for you (ops build), then run it.

As you'll see, ops init created a simple boilerplate op which showcases some of the SDK features.

Next, let's learn how to customize the op. Exit the currently running op by typing CTRL + c.

5. Customize your op

Let's take a look at the boilerplate op code:

$ ls my-first-op/

The key files here are the index.js and ops.yml, you'll want to modify those to customize your op.

This creates a Docker image that wraps your op. You can confirm this worked by running:

$ docker images

Alternatively, you can proceed directly to the build step:

$ ops build my-first-op

Your new op should be at the top. Next, let's run it:

$ ops run my-first-op

Nice, you just built your first Op.

Continue to edit and rebuild your Op and until you're happy with the result.

5. Publish an op

So far you have created a new op, but only you can see and run it.

Let's upload it to the ops registry so you can share it with others:

$ ops publish my-first-op

By default, your op will be published to your current team's registry.

You can be signed in to only one team at a time. To verify your current team you are on, run this:

$ ops whoami

The Op will be published to your team once it uploads successfully.

You'll now find it belongs to your private team when you search:

$ ops search

To verify that everything is working correctly, you can delete all of the images from your localhost and test run the Op:

$ docker rmi -f $(docker images -qa) && ops run my-first-op

Note: This last step will delete ALL docker images on your localhost‼️