Ops Reference

ops.yml

The ops.yml file structures how your Op will run and provides information for how other users will be able to interact with it. The run line of the yml is the entrypoint command that is run as the final step of the Dockerfile to trigger your Op. The sample ops.yml file created by ops init for the Command template is shown below.

version: "1"
ops:
    # Unique identifier for your op (required)
  - name: helloworld

    # Short description for what your op does (required)
    description: My first Command Op.

    # Determines whether this version of the op is visible to other people
    public: false

    # A link to a public git repo. The README.md will be displayed on
    # your Op page in our Community Registry
    sourceCodeURL: ""

    # Command that is executed when op is started ("npm start",
    # "./start_script.sh", etc.) (required)
    run: node /ops/index.js

    # Provide required environment variables for your op; to access,
    # use the platform specific API, e.g. `process.env` for NodeJS To
    # use environment variables from the Host, use the $ prefix:
    env:
      - "USER=world"
      - "OPS_ACCESS_TOKEN"
      - "OPS_ENV_VAR=$HOST_ENV_VAR"

    # Whitelist files and folders to be included in the published op's WORKDIR
    src:
      - Dockerfile
      - index.js
      - demo.js
      - constants
      - prompts
      - utils
      - package.json
      - .dockerignore

    # If set to `true`, binds the host's current working directory to
    # `/cwd`; default value: `false` - working directory `/ops`
    mountCwd: false

    # If set to `true`, binds the host's home directory to `/root`;
    # default value: `false`
    mountHome: false

    # Bind additional volumes; trail the string accordingly to
    # configure permissions for either read-only (:ro) or write (:w)
    # access (example: ~/tmp:/root/tmp will bind lefthand directory in
    # host to righthand directory in ops)
    bind:
      - "/tmp:/tmp"

    # Map ports for your op container
    port:
      - 3000:3000

    # Configure the output for when your op is run with `op --help` or `op -h`
    help:
      usage: "Your first hello-world op"
      arguments:
        username: "Your username"
        email: "Your email"
      options:
        build: "Build flag"
        clear: "Clears"

Dockerfile

The Dockerfile provides the build instructions to include all of the files and software packages necessary to run the Op. The sample Dockerfile created by the ops init for the Command template is shown below.

############################
# Build container
############################
FROM node:10-alpine AS dep

WORKDIR /ops

RUN apk add python make
ADD package.json .
RUN npm install

ADD . .

############################
# Final container
############################
FROM node:10-alpine

WORKDIR /ops

COPY --from=dep /ops .