Webinar

October 12, 2021 12:00 PM EDT
The future of RPA: Migrating to Gen-2 toolsOctober 12, 2021 12:00 PM EDT
Are you wondering if it is worth the time and money to switch RPA platforms? Join our RPA experts as they discuss all things migration & Gen-2 tools.

How to set up local container running Robocorp Workforce Agent

Control Room allows you to manage, orchestrate, and schedule the execution of your software robots in a central place. Control Room has Processes, which contain steps that Runtime Environments execute.

We instruct how to set up a local Docker container for running Robocorp Workforce Agent Core. This enables isolating the Robocorp Workforce Agent Core into ephemeral instances that can be easily managed.

Prerequisites

  • Docker build Environments
  • Robocorp Workforce Agent Core and RCC

Limitations

A Docker container does not have UI access to applications. This means you can run so-called headless operations and access the container's resources but cannot, for example, take screenshots of Windows application UI's.

Container setup

Static container

Static container refers to a container linked to Control Room at build time and will be seen in Control Room as a single environment every time it is started.

Insert the Control Room environment link token and name at build time with the --build-arg argument, and then build and run the image as a container, and the environment will be visible in the cloud.

Dockerfile

# Select the base image
FROM ubuntu:18.04

ARG NAME
ARG LINK_TOKEN

# Set all variables that affect programs to follow the same encoding
ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8

# Install here all the software your process needs in order to execute
RUN apt-get update --fix-missing && \
    apt-get install -y wget bzip2 ca-certificates curl bash chromium-browser chromium-chromedriver build-essential && \
    apt-get install -y fonts-indic fonts-noto fonts-noto-cjk && \
    apt-get install -y zip libdbus-glib-1-2 && \
    export PATH=$PATH:/usr/lib/chromium-browser/ && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* \
    echo "Chromium Version: " && chromium-browser --product-version && chromedriver --version

# Running as non sudo user 'worker'
RUN useradd --no-log-init --system --create-home --shell /bin/bash worker
USER worker
WORKDIR /home/worker

# Create the agent inside the image
RUN mkdir -p /home/worker/bin && \
    mkdir -p /home/worker/.robocorp \
    mkdir -p /home/worker/bin/conda && \
    mkdir -p /home/worker/instance
RUN curl --silent --show-error --fail -o /home/worker/bin/robocorp-workforce-agent-core https://downloads.robocorp.com/workforce-agent-core/releases/latest/linux64/robocorp-workforce-agent-core
RUN chmod +x /home/worker/bin/robocorp-workforce-agent-core

# initialize the Agent Core
RUN /home/worker/bin/robocorp-workforce-agent-core init --log-level TRACE --rcc-exec-path /home/worker/bin/rcc

# Link the App to Control Room
RUN /home/worker/bin/robocorp-workforce-agent-core link "$LINK_TOKEN" --name "$NAME" --instance-path /home/worker/instance

ENTRYPOINT [ "/home/worker/bin/robocorp-workforce-agent-core", "start", "--instance-path", "/home/worker/instance" ]

Commands

Build:

docker image build --tag robocorpapp_static_container:1.0 --build-arg NAME=<insert name> --build-arg LINK_TOKEN=<insert link token> path/to/Dockerfile

Run:

docker run -dit robocorpapp_static_container:1.0

Dynamic container

Dynamic container refers to a container that is linked at run time. This means that a new environment is visible at Control Room every time the container is run.

All workforce processes need to be set to use this environment each time a new environment is created.

Build the image from Dockerfile and then insert the Control Room token and name at run time as an environment variable to the run command with the -e run argument to make the environment visible in Control Room.

Dockerfile

# Select the base image
FROM ubuntu:18.04

# Set all variables that affect programs to follow same encoding
ENV LANG=C.UTF-8 LANGUAGE=C.UTF-8 LC_ALL=C.UTF-8

# Install here all the software your process needs in order to execute
RUN apt-get update --fix-missing && \
    apt-get install -y wget bzip2 ca-certificates curl bash chromium-browser chromium-chromedriver build-essential && \
    apt-get install -y fonts-indic fonts-noto fonts-noto-cjk && \
    apt-get install -y zip libdbus-glib-1-2 && \
    export PATH=$PATH:/usr/lib/chromium-browser/ && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* \
    echo "Chromium Version: " && chromium-browser --product-version && chromedriver --version

# Running as non sudo user 'worker'
RUN useradd --no-log-init --system --create-home --shell /bin/bash worker
USER worker
WORKDIR /home/worker

# Create the agent inside the image
RUN mkdir -p /home/worker/bin && \
    mkdir -p /home/worker/.robocorp \
    mkdir -p /home/worker/bin/conda && \
    mkdir -p /home/worker/instance
RUN curl --silent --show-error --fail -o /home/worker/bin/robocorp-workforce-agent-core https://downloads.robocorp.com/workforce-agent-core/releases/latest/linux64/robocorp-workforce-agent-core
RUN chmod +x /home/worker/bin/robocorp-workforce-agent-core

# initialize the Agent Core
RUN /home/worker/bin/robocorp-workforce-agent-core init --log-level TRACE --rcc-exec-path /home/worker/bin/rcc

# Set the local scripts in place
COPY ./start.sh start.sh

ENTRYPOINT [ "./start.sh" ]

Start script

#!/bin/sh

echo "Linking the Agent with name $NAME and token $LINK_TOKEN"
./bin/robocorp-workforce-agent-core link $LINK_TOKEN --name $NAME --instance-path /home/worker/instance
echo "Linking succeeded"

echo "Starting the Agent..."
./bin/robocorp-workforce-agent-core start --instance-path /home/worker/instance

Make sure the start script is executable by running:

chmod +x /path/to/start.sh

Commands

Build:

docker image build --tag robocorpapp_dynamic_container:1.0 path/to/Dockerfile

Run:

docker run -dit -e NAME=<insert name> -e LINK_TOKEN=<insert link token> robocorpapp_dynamic_container:1.0

Runtime configuration

The runtime configuration can be modified to set what commands are allowed to run by default in the instance.

If you want to modify the runtime configuration, create a rtconfig.yml (example below) file and copy it to the Docker instance by adding copy command to Docker file: COPY path/to/rtconfig.yml instance/rtconfig.yml.

#
# Robocorp Workforce Agent Core configuration
#

run:
  #
  # Specify commands allowed to be executed.
  #
  # Incoming commands are matched against allowed commands list using micromatch:
  #  - micromatch.isMatch(requestedCommand, allowedCommandsArray)
  #  - See https://www.npmjs.com/package/micromatch#ismatch for reference
  #
  # Recommendation: Apply the principle of least privilege. Use exact match
  # with a single command when use case allows.
  #
  allowedCommands:
    # OpenRPA convention: task runner script in scripts/
    - entrypoints/(*.bat|*.sh|*.cmd)
    - scripts/(*.bat|*.sh|*.cmd)
    - (*.bat|*.sh|*.cmd)

    # Print current date/time example.
    # /T is needed on Windows to only output the current date/time.
    - time
    - time /T
    - date
    - date /T

    # Allow everything. Use with caution, e.g., only within the development
    # sandbox.
    - '**'

dataTransfer:
  # Specify what data is allowed to be sent to the cloud from the executed
  # process.
  #
  # When data transfer is enabled, the data including build artifacts, worker
  # console log, and console output are sent to the cloud.
  #
  # If disabled, only the operationally mandatory control messages between
  # cloud and worker are sent to the cloud, and will be printed in the cloud
  # run console output window. To disable data transfer set option
  # 'disable: true'.
  #
  disable: false

Common issues

  • Make sure the start.sh script uses Linux line endings (LF)
August 18, 2021