MID Server on a Docker Container
[Music] hey everyone it's justin thank you for watching in this video i'm going to show me building a mid server inside a docker container inside windows on my pc and connecting it to my personal developer instance or a pdi that's right lots going on in this video we've got to get right to it because there's a lot to cover first let me show you first step you do when setting up a mid server is you got to set up a user in order for that mid server to connect i have one i called it windows docker mido ones you can see here i've got a user id a first name and a last name the bare minimum in order to set up that person or set up that user i also had to set a password because in my pdi i have it left to where i can't actually write a password so that generates a password and then you've got to uncheck this password needs reset so you can actually use that password and then last piece here is i granted it the role of mid server granting it the role of mid server actually grants it the soap rolls which is how the mid server actually talks to your servicenow instance after that's all done that only takes a few minutes you can go to this downloads page under mid server and on the downloads page there are two docker recipes you have of choice to use there's windows and there's linux i used the linux docker recipe not for any particular reason other than i know it's probably lighter weight and smaller and runs faster so i clicked the download icon and that downloaded a nice zip file to my computer i'll show you that zip file what that looks like so i've got it here there's a zip file i extracted it to this folder and in that folder you can see what comes in here and this is all provided by servicenow i didn't have to do anything with it what i didn't do the first time that i did this is i didn't specify a docker tag when i was building it so you'll see here i'm gonna bring over notepad plus plus and you can see this docker tag now i didn't supply this or i didn't supply the path to this and so it built an image but it was like blank colon blank it was really annoying so i'm going to copy that to my clipboard so i have it i'm also going to show you docker for desktop that i have no containers i have no images i'm recording this live uh no very little editing if any will be on this so i want you to see the real deal and how this works next thing i want to run is windows subsystem for linux or wsl and this basically is a terminal window inside of windows that i can run commands on and in this case i'm going to run docker build and i'm going to provide the path to that particular docker file or that docker recipe that i just downloaded so i know that is in the users folder under my first name with no n and then in my onedrive folder and then in my onedrive folder i have a docker recipes and then you saw there was a folder that started with mid there now i do want to specify that tag so i'm just going to dash dash tag and then i'm going to paste in that value from that env file goes inside the docker recipe i'm going to hit enter and it's going to go off and build now while this is building i want to show you a couple of things number one so you see this real time and how long it takes number two i gotta explain what the heck's going on what is justin doing so i basically am using my pdi to build this really cool project you're going to find out more about that eventually and as part of that it's going to have data so it's not going to just be backing up an app to github which if you haven't seen that video you should go check out the video of me doing my source control and backing up my applications that way if i blow away my pdi or it's gone i can actually restore the application that i've been working on but importantly there's going to be data there's going to be data on tables that i want to back up in my case there's going to be tables within my app and then i'm also going to manage my to-do list the things that do the things that i want to manage in a table and that's going to be data that i don't want to lose because if i lose it then i'd lose the whole purpose of this exercise that i'm going through so with a mid server in servicenow i can drop files using export sets on the limit server and then i can from that mid server in this case from a container i can then copy that out to locations one of those could be my external hard drive on my computer it could be on my computer it could be to amazon s3 it could be in a onedrive it could be a dropbox it could be at all these different places i have a bunch of ideas about what i want to do but i need to get this mid server up and running so that i'm able to do that once this mid server is up and running i'm going to provided a path to a uh to a file let me just pull this over here so you can see it and we'll just have this running in the background let's see if it lets me open that in a new window it is not being nice so let's just drag over this whole thing here okay so right above my head you can see inside this file this is the configuration for the mid server so i provided it at the url to my pdi i've got it blocked out right now i gave it that user windows docker middle one that i created and i showed you the beginning there's a big long password that i took out of here so you don't see it and then there's a server name so this is the absolute minimum required now should you be providing mid instance password in clear text on a configuration file in production probably not for me it's my pdi it's not a big deal i'm in control of this docker container i have pretty good security around my stuff so i'm not too worried about it but your mileage may vary you may not want to store your password in a plain text file like that so we're going to provide that parameter for how to get to that environment file when the docker image is run so what we're doing now that's just cleaning up is it's building an image you're going to see when i pull up the images it's going to be about a gigabyte in size and that will be what gets run when we actually run the docker container which is going to be our mid server which will connect to my pdi and i'll show you how that happens so we're about done here it's on the last stage eight of nine and we're going to export it and we're almost there exporting the image done so that image is built we no longer need that particular piece but i want to show you what the image looks like so let's come in here there it is i didn't even have to hit refresh it's mid it's tagged with tokyo it's got an emitter id and everything i need and there's that file size of 1.08 gigabytes i told you about so pretty slim pretty fast time to actually realize that and get it built so the last thing i need to do is run this so notice i have no containers running so i need to run this image and the way i'm going to do that is back in here i'm just going to clear screen for you real quick and i'm going to do docker run and then we're going to specify that environment file which is going to be in the same crazy location of before so we're gonna have to go users uh users with an s just jus ti and then my onedrive and then in my docker recipes and then that big long folder name and then in there there's going to be mid.emv it's going to be the file and then the image that i want to run is what i need to specify next and that is right here on my screen i'm just going to specify that image id just to be sure it does the right one so we'll just go b 0 a1 cc 269921 enter and it should start that mid server you can see it starting up now it's waiting for the mid server and it's going to go do a bunch of stuff all right so a bunch of stuff is going to happen now if i come back over here click on containers we see the charming clam it's a random name that's generated for the container it is now running once these containers are running you can actually go see the log files that are running there i'll just go and minimize that one in the background so i can see all that if i want to click on it again i can see the stats this is neat to see the impact especially when i start backing things up like i talked about how much memory is it using how much cpu that's interesting 370 percent and then what's the network i o or input output so i could see all that on my container and i can get to a command line interface for the container itself that's going to be important here in the end now while that's up and running it's starting to talk to servicenow so let's go back to service now and look at the servers so we see now it found that it's got the windows dock windows docker middle one it's got a host name it's got all that it just started on september 7th at 11 48 pacific time but it's not been validated um so it's doing a bunch of stuff i want to make sure that it's close to done so it's checking packages and it did look like it installed some things it's connecting to a channel for mid server should be okay i'm going to go ahead and open up the mid server configuration i'm going to validate it right so notice here its status is up validated as no and it hasn't have a validated date and time right so i'm going to go ahead and part that validation is it's going to restart the server so we'll just leave all that default and hit save and that validation should start and just to see what that looks like on both sides i'll pull up that window there let's see grab that down a little bit because this is going to change now that just went down so this is it restarting the mid server you can see it just went down it is terminating you can see there and that's actually kind of behind my head so you probably can't see it let's shrink this a little bit there we go that that's good positioning on my head so you can see these fields as they get updated it did stop the server here it is coming back up you can see the startup sequencer running on the logs over here and we should see yep status just changed up right here it is now validated so that is a valid mid server and we are good to go that mid server is up and running now for the final piece of this proof of concept to make sure it does what i want let's go build an export set real quick if you're not familiar with an export set is it's a way to get data out of servicenow and drop it on a mid server so i'm going to create a new export set and we'll just call this the incident table this won't be what i actually use but it's just a good test to make sure i'm actually talking to it i don't have a definition but i know where i want to export it to so i'm going to go ahead and pick a target and actually that's the target i set up earlier so i don't want to use that one so let's click new and we'll just call this incident docker image and we'll pick this mid server and the file path i'm going to leave there it's going to actually be in a folder called export which is fine and this will be demo uh export set for recording so we'll see that that looks a little bit different than my other one there we go and the what to export is the export definition i think i will that should be okay because it's the same incident table i set up before let's see if i can actually show you what that looks like so you don't think i'm hiding anything there so it's just grabbing short description category updated caller id so i could go change what fields it's actually exporting but that's the definition i'll go ahead and save this definition and then the next thing i'm going to do is i'm just going to test the export of those 20 records so let's see their test export of 20 records and let's go ahead and click that and that should kick that off and we should see that actually run now if everything works great it'll say it completed success it actually worked right so that's what i want to see now let's head back over to the docker image right so this is the log file still running i'm going to switch over to the command line interface because i want to see what that actually looks like so now i'm on the actual container inside and on these it actually lives in this folder so under opt mid server folder i think there's an agent yep so i'm going to go into the agent folder and then i've got this export folder that you see right here so that's where my file should be if that actually works so let's go in there and see look at that incidenttable.csv i'm just going to open it up in vi and see what that looks like there you go i've got a bunch of incident data looks like about 20 records like i'd want so let's get out of there and now that i have that let's come over here this is now my windows subsystem for linux i'm going to clear the screen again and i'm going to do a docker uh oh it's still i mean it's control c out of this or control where does that break which killed it okay so let's go to wsl again should open new terminal oh yeah good okay so i'm going to do a doctor cp and um the image the it's container that's actually running is let's see charming clam so we'll do farming hellam and then i need to specify that same path which is slash opt slash um snc uh shoot what was that again let's go back to the container since i didn't memorize that i memorized a lot of things but that was snc underscore mid server so smc underscored mid underscore server and then it was slash agent and then it was slash export and then it was uh incident underscore table dot csv so i want to put that into let's just throw it into my onedrive folder where everything else was so we'll do users slash j-u-s-t-i slash onedrive and slash i think it was docker recipes right that's what i had open so let's go open that folder before i hit enter and see under daca recipes i just got my zip file in my folder there at the moment so let's come back here and we should see when i do this it should copy that file over to this docker recipes folder so i hit enter it executed the command and there it is look it just popped up incident table.csv so i just got a table export it was a test right but i got a table export out of my pdi let's just open this with excel i got it out of my pdi into a container on a docker image for a mid server and then into a spreadsheet that now is really tiny um on my local pc so if you can imagine moving around stuff automatically and backing things up this could be really really helpful so you just saw me build a mid server in a docker container on windows and connect it to my pdi and export a file using export sets all within this video i hope you found it helpful if you did please like please subscribe or share it with somebody who you think might be interested in doing crazy things with their pdi and until next time don't forget to always be learning [Music] you
https://www.youtube.com/watch?v=1Wc1fm-xMO8