UiPath robot in a Docker image

hello everyone my name is not a bad one

whistles engineer with uipath I'm based

in Milan Australia and today we will

continue our series of webinars

regarding applying CI CD concepts to RP

a development the last time we discussed

the steps that are part of a seriously

pipeline and one of the steps the first

one was the build step in which the

developer pushes his code to a git

repository which triggers a pipeline we

are using in our example and Azure

pipeline and that pipeline will need an

agent running environment where all our

commands are executed and we will look

at creating a docker image from which a

docker container will be created which

will actually run the agent that docker

image needs to contain the iPad robot

and we also need a way of communicating

with the orchestrator and in our case

we're going to use a Porsche library so

we want to have this docker image built

and made available to agile pipelines

and therefore we will need to host it

somewhere in the crowd the fact that I

have this image on my machine will not

really help so we will start with some

prerequisite today I've created a github

repository you are Patrick robot which

will host our code I've also created a

resource group within my subscription

I've named it Europe at good practices

resource group and I've also created a

project in my ear' path in my a short

DevOps account we are packed with

practices here we will create the

pipelines that we're gonna we will

reference throughout the webinar series

of webinars

I have also cloned the github repository

on my machine and we are now looking at

the daka file

so we will start with an image obviously

it's going to be a Windows image so we

will start with Windows server core as

the base docker image and let's see we

have looking for the latest image and

this is it and we start from that so

from our steps would be something like

this we're gonna download MSI installer

from the web and this is the download

link your home / drive the other MSI and

normally we would install this so we

would also add an output we're gonna

store it say locally to get back to do

my side and then we're gonna run em

aside locally we need to look at your

arguments to see exact what is the the

correct command to install it silently

then we want to add a local some

teachers desktop feature and robot so

have the local equals desktop feature

and also going out just all the robot

and let's see let's install it in a

specific location and we also need to

provide an entry point to our container

CMD should be fine so the very basic

image that will contain our UI path dr.

ice robot will be this one let's build

it let's give it a name you have class

robot let's say and let's see how it

goes in the meantime we need to prepare

our cloud we will need a container

registry within our other resource block

to host the image will create we've

created so I think it's all container

registry if I correctly cool most of

them are gonna be to Australia South

East and let's give it a name let's say

path this will take a little bit of time

to to be created so in the meantime I'm

gonna go to my azure DevOps and I will

start critical pipeline this pipeline

will have the purpose of taking my

docker file and building the docker

image and then pushing it to the

container edges we've just created in

Microsoft Azure so let's create a new


it will be treated by a github event as

we discussed so me as a developer I'm

pushing code to github to a specific


I want this repository to be linked to

my Asscher DevOps and I wanted to

trigger the pipeline so let's look for

the repository it's convenient to the

last one and let's do they have some


pipeline configurations let's start with

this one

docker the and push an image to a shore

container registry as you can see

because I'm single sign I have single

sign-on between those two environments

my agile devops

in my as a portal I can just do a little

bit of quick click without a lot of

configuration as a service is a lot

easier to get started with and we also

have the container registry which we

have built here so if we go to our

reporter within our resource group we

have a container registry called uipath

robot which is pre-populated here in a

drop down list which is really


let's give it a shorter name shall we to

the image let's say you have a robot

it's just easier to remember I guess

let's validate so as a DevOps has

created for us a pipeline and the

pipeline has some variables here and it

has also if we go to our project

settings service connections it has


two connections one of them is to github

meaning that every commit and push that

the developer performs into github gets

you is used to trigger a pipeline

basically it's sort of like a web hook

the other connection is the UI path

robot to the docker registry as we said

here we are in a DevOps and we want

Azure DevOps build agent to have the

permission to not only build the image

which it builds locally but also push it

to the docker registry the docker

registry is part of a sure is on we find

it in Azure portal within a resource

group and obviously we don't want

everyone to have the right to push and

pull to that registry is our registry

and therefore Azure DevOps will create

this will create a service principle

which will be used to authenticate the

azure DevOps

agent performing a build to the azure

container registry and we can find that

here in app registrations we will find

all the applications that under our

credentials have created a service

principle so this service principle will

have certain permissions and if we copy

this name which you don't have to

remember obviously it's a very long name

and we go into our container registry

into access control and we just look

here into role assignments will find the

fact that this application has a

contributor role on this instance on

this resource now looking at our newly

created pipeline we can find the

structure on

they're wolves yeah pipeline and we'll

find the schema here it's we're gonna

use a very small subset of all the items

in the schema we will have a trigger for

master from now and we'll define some

variables which will configure the way

the pipeline runs but basically we'll

build a local file which has the name

toka file we will tag it with a build ID

which is which is generated by the agile

pipelines for every build and it will

target the repository we've created and

the service connection that was created

for us a little bit earlier I will save

the yellow pipeline which will also

commit it to github if I'm going to

github and I do if and i refresh I will

see the fact that a new file was added

to my upholstery the first time the

pipeline will not run successfully

because the docker file is anything we

haven't pushed anything with a git

repository so if we navigate to the to

the build we can see the fact that the

docker file cannot be empty which is

absolutely to be expected we're not

concerned about that and our local build

is complete let's see how when let's go

docker run my key robot right now the

docker on my machine will create a

container from that image and we have a

command line within that container

first thing we notice is the fact that

we have the MSI installer here and we

also have the installation folder let's

go inside this folder have a very large

number of files we are just interested

in one functionality we're interested in

UI robot with a PAC functionality which

exists obviously we don't have an error

because we don't have a project to

actually build but we are happy with the

results so far I will exit and there is

one more thing we need to be careful

mindful of let's do a deep hole if you

remember we have this new file the other

pipeline file which was created by a

DevOps for us and was pushed to our

github repo here and we want this file

to end up on our machine as well so

we'll just do a git pull and this is the

file we do have to make one small

adjustment a sure DevOps has a pool of

build agents and they are either Ubuntu

or Windows I think they have a Mac OS as

well but we cannot build this image on

an Ubuntu VM we need to build it on a

Windows p.m. so let's see how we are

we've quantified those two files we know

let's see let's commit with message


and we should see momentarily the fact

that we've created this commit it's

great now if we go into our Asher DevOps

and we look at the pipeline runs we see

the fact that one of them was just

kicked off the initial build will take a

while we take around an hour because it

has to push all the layers of the image

and if you look on our machine we see a

docker image list with the fact that our

image is quite big it's not a small

image it's a very big image so that will

take a while 40 minutes - 50 minutes on

the first one but because we have

different layers and the first layer is

quite substantial to begin with we see

the fact that Microsoft has a 5 gigabyte

layer this layer will be cached so once

we do the first push into our answer

container registry that subsequent

pushes will not we just keep this will

be cached we don't have to push it so

the first one will be a little bit

longer but that's fine because it's

going to give us some time to fix some

other issue and we if we look at our

docker image we see the fact that we

have five layers and that we download an

MSI installer we create a local path and

we run the MSI installer obviously after

this we would probably want to remove

the MSI installer because it doesn't add

any value to the image we we should

remove it and furthermore we'd probably

want to reduce number of layers if you

go to docker and we look at good

practices or best practices we see the

fact that they suggest instead of having

multiple layers to install just one

piece of software we should merge them

into one layer so in one step

perform the

actual download of the file installation

and removal of the installation kit of

the installation MSI now we are running

on Windows and therefore we don't have

coral we don't have W get the command

line we're gonna have to use PowerShell

for this so we're going to look at our

docker file and try to remove these

three layers and merge them all into one

so instead of ad which is a docker

command to download and/or copy files

we're gonna do run and we're gonna run

PowerShell let's do this PowerShell and

let's first solve our our installation

path let's say - item type if I remember

correctly let's see and this is - name

we can always come back and fix them if

you make typing errors which is

something let's say let's say invoke web

request and I think this one comes with

- well I'm putting semi column and tag


I don't need this anymore

let's start process we're going to start

this process we need to pass - I'll pull

this another pass this target at least

and we're gonna wait for it to finish

and we want to remove item we want to

remove the installation installation MSI

at the end we don't want it to shape it

with a good image it just adds weight to

meet with the real value to it so let's

do this and minus force so it doesn't

ask us if I think we are and in the

meantime let's see how our pipeline is

doing so this is the log from the build

agent and we see the fact that we have

started with our windows image we've

downloaded built the install MSI we've

created the installation part we have

installed you have a studio we've

created the entry point and our job has

been completed with actually that's

great so going into Azure in our

container registry upholsteries we see

the fact that we have a new repository

called uipath robot and it has a tag of

five five being the fifth run of this

pipeline in its lifetime and after a

little bit of tinkering our build is

done let's see how it

yeah robot and the first thing to notice

is that we no longer have the

installation kit the installation MSI

and which is good and we still have the

iPad is installed locally let's see

also we've just shaved a quite

significant part of a bit of our image

size which is also very good easily

smaller is better with docker images

let's commit our changes let's call the

update and let's push this our commit

will become visible here and if we go

into our other levels we see that the

new build has been triggered and the new

version of our image will be built and

then pushed to the azure to contain

registry one more thing

we need to think of before we move on we

have discussed the fact that we want to

have a system or setup in which the

build artifact is progressed through the

pipeline and it is pushed to

orchestrators along the way this means

that our pipeline or our build agent not

only needs to have the ability to create

our package but also needs to have the

ability to interact with Orchestrator

and for this we're gonna need to have

one more thing added to the to our image

we will need to have the iPass

powershell library installed which you

can find on github it is a level which

allows us to hit the orchestrator

exposed api and interact with it and the

installation is quite straightforward we

just need to add these three commands so

let's go back to our doctor file we have

successfully installed studio so far and

we want to just add the installation the

porsche installation commands which just

is called a package provider add the

repository install the module let's

let's build it locally see how it goes

and in the meantime we can probably

check on our pipeline our build has just

started and it should be ready quite

quickly while our build is running let's

just have a look at the readme for our

project I've added a badge for the azure

pipeline which you can find in pipelines

status badge and you can just copy it

and add it to your repository this will

see if the latest push was successful or

not and a small diagram which highlights

what worked what we've done today we've

paid the subscription within our

subscription we've created a resource


and we need a resource group we've

created on our container registry in

Azure DevOps we've created the project

and we've created a pipeline that

pipeline is being triggered by a github

repository and it contains running an

agent running on Windows which will

download the code our docker file and we

will build locally and then we use the

service principle to authenticate to the

azure container registry and push the

image I hope you found this useful you

will find the git repo and resources in

the video description see you next time