Written by

Senior Startups and Community Programs Manager at InterSystems Corporation
Article Evgeny Shvarov · Jan 25, 2024 2m read

Your Favorite IRIS Terminal Aliases In Docker Dev Environment!

Hi Devs!

Recently I was impressed by @Dan Pasco's article where he shares also how he uses terminal aliases. 

Terminal aliases is a very powerful tool for developers and sys admins if you often need to call some cumbersome terminal expressions and make it shorter and cleaner. Here is the documentation.
Yes! 

But what about Docker environments? What if you are fan of Docker dev environments but also want to keep using your favorite aliases with Docker as well?

Turned out it is very possible.

Just add .iris_init file (example) into your GitHub repository and copy it into the home folder of IRIS user - /home/irisowner in this case. Which can be nicely done with this command in Dockerfile:

COPY .iris_init /home/irisowner/.iris_init

I've added a few in basic objectscript and iris-dev templates (mostly borrowed from isc-one-liners project):

:alias enablebi do EnableDeepSee^%SYS.cspServer("/csp/"_$zcvt($namespace,"L")) ;
:alias ssl x "n $namespace set $namespace=""%SYS"", name=$S(""$1""="""":""DefaultSSL"",1:""$1"") do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name)" ;
:alias createdb do $SYSTEM.SQL.Execute("CREATE DATABASE $1") ;
:alias installipm s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ISC.FeatureTracker.SSL.Config" d r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c") ;
:alias add%all x "n $namespace set $namespace=""%SYS"",P(""Globals"")=""%DEFAULTDB"",sc=##class(Config.Namespaces).Create(""%All"",.P)" ;
:alias exportglobal d $System.OBJ.Export("$1.GBL","$2$1.xml") ;

Here is how you can use them, e.g. Global export:

USER>:exportglobal AAA /home/irisowner/
d $System.OBJ.Export("AAA.GBL","/home/irisowner/AAA.xml") ;

Exporting to XML started on 01/25/2024 11:58:37
Exporting global: ^AAA
Export finished successfully.

USER>

Or add ssl configuration with a specific name:

USER>:ssl web
x "n $namespace set $namespace=""%SYS"", name=$S(""web""="""":""DefaultSSL"",1:""web"") do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name)" ;

USER>

Hope you find it useful as I do! :)

Please, fill free to share your favorite aliases - we'll add it in the basic template as well.

Comments

Robert Cemper  Feb 7, 2024 to Evgeny Shvarov

for easy reading, not a oneliner yet.
 

new$namespace,host,ipaddr,p
znspace"%SYS"set host=$system.INetInfo.LocalHostName()
set ipaddr=$system.INetInfo.HostNameToAddr(host)
do##class(Config.Startup).Get(.p)
set url="http://"_ipaddr_":"_p("WebServerPort")_"/csp/sys/UtilHome.csp"kill p,host,ipaddr 
quitzw url
0
Evgeny Shvarov  Feb 7, 2024 to Robert Cemper

That works, Robert, thank you! Not for docker use unfortunately

0
Brett Saviano  Feb 7, 2024 to Evgeny Shvarov

@Evgeny.ShvarovThis should work:

Do##class(%Studio.General).GetWebServerPort(,,,.url) Write url,"csp/sys/UtilHome.csp"Kill url
0
Evgeny Shvarov  Feb 7, 2024 to Brett Saviano

Nice! Thank you @Brett Saviano! 

And it works for host versions nicely! But of course if it is a docker image there could be a ports mapping. e.g. if I start iris with the following command:

docker run --rm --name iris-demo -d -p 9091:1972 -p 9092:52773   intersystemsdc/irishealth-community:preview

and open terminal with:

docker exec -it iris-demo iris session iris

then the command gives us:

USER>Do##class(%Studio.General).GetWebServerPort(,,,.url) Write url,"csp/sys/UtilHome.csp"Kill url

http://172.17.0.2:52773/csp/sys/UtilHome.csp

and the working one is:

http://localhost:19092/csp/sys/UtilHome.csp

Maybe it is not possible at all for docker. 

Unless we setup a special global intentionally during the docker image build.

0
Evgeny Shvarov  Feb 7, 2024 to Robert Cemper

This is a fantastic discussion. Is there any service other than @Lorenzo Scalese's that can provide host IP and port for a docker iris? e.g. to be able to use it during development? 

0