Coding Dockerfile with InterSystems ObjectScript
Those who use Dockerfile to work with InterSystems IRIS often need to execute several lines of ObjectScript. For me, this was a game of "escaping this and that" every time just to shoot a few commands on ObjectScript to IRIS. Ideally, I'd prefer to code ObjectScript without any quotes and escaping.
Recently I found a nice "hack" on how this could be improved to exactly this state. I got this from @Dmitry Maslennikov's repo and this lets you use Objectscript in a way as you would type it in IRIS terminal.
Here is what you have in dockerfile:
/// COPY irissession.sh / SHELL ["/irissession.sh"] RUN \ do $SYSTEM.OBJ.Load("Installer.cls", "ck") \ set sc = ##class(App.Installer).setup() # bringing the standard shell back SHELL ["/bin/bash", "-c"] CMD [ "-l", "/usr/irissys/mgr/messages.log" ] ///
The trick is that before executing ObjectScript we call irisession.sh which does the following:
1. starts IRIS
2. Calls some "standard" ObjectScript commands and brings control to Dockerfile to let you introduce lines in ObjectScript - "$@" instruction.
3. stops IRIS
Check the content of the irissession.sh:
#!/bin/bash iris start $ISC_PACKAGE_INSTANCENAME quietly cat << EOF | iris session $ISC_PACKAGE_INSTANCENAME -U %SYS do ##class(%SYSTEM.Process).CurrentDirectory("$PWD") $@ if '\$Get(sc) do ##class(%SYSTEM.Process).Process.Terminate(, 1) do ##class(SYS.Container).QuiesceForBundling() do ##class(SYS.Container).SetMonitorStateOK("irisowner") Do ##class(Security.Users).UnExpireUserPasswords("*") halt EOF exit=$? iris stop $ISC_PACKAGE_INSTANCENAME quietly exit $exit
This $@ expects one RUN command in Dockerfile which will contain only ObjectScript. If you need to use some more commands in Dockerfile bring the control back with standard shell:
# bringing the standard shell back SHELL ["/bin/bash", "-c"] CMD [ "-l", "/usr/irissys/mgr/messages.log" ]
This code is introduced into IRIS community template to let you start using ObjectScript in your IRIS solutions with accurate and readable code.
Learn how to use Github templates with IRIS in this video.