Joe Bogner Posted a Docker image for running J on a tiny core docker image on 
JChat forum.

http://www.jsoftware.com/pipermail/chat/2016-November/007158.html 
<http://www.jsoftware.com/pipermail/chat/2016-November/007158.html>

I happened across the post doing a search on the Forums. It gave me a chance to 
come up to speed on Docker and ultimately I took a stab at creating an image to 
create a Docker container that would run J under the openwhisk/dockerskeleton 
distribution and have been able to set up an OpenWhisk action on my IBM Bluemix 
account that calls a jconsole script via the python open whisk miniderver 
installed in the open whisk/dockerskeleton distro. 

To do this I borrowed from Joe Bogner’s Dockerfile and set up the Linux J 
distribution for 805. However, under Alpine this does not work because of some 
low level functions that are in glibc but are not in the musl c distribution 
that is standard with Alpine. Luckily J is not the only program that relies on 
these functions and by borrowing the commands to set up glibc under this 
docker/image I was able to create an Alpine Docker image that will run jconsole 
scripts using #!/home/j805/bin/jconsole 

The docker images can be found at: 

https://cloud.docker.com/swarm/porteverglades/repository/docker/porteverglades/alpine-j-whisk/general
 
<https://cloud.docker.com/swarm/porteverglades/repository/docker/porteverglades/alpine-j-whisk/general>

And the source files at 

https://github.com/tmcguirefl/alpine-j-whisk 
<https://github.com/tmcguirefl/alpine-j-whisk>

The pertinent files are action.sh:

#!/home/j805/bin/jconsole
load '~addons/convert/json/json.ijs'
load '~addons/convert/misc/base64.ijs'
load '~temp/main.ijs'

echo main ARGV
exit ‘'


And main.ijs (which is where most of the action logic is accomplished):


NB. main.ijs - J OpenWhisk script
NB.      expects JSON in arg2 of boxed ARGV input
NB.      returns JSON output
main =: 3 : 0
  outstr =. '{ "result" : { '
  for_i. y do.
    if. '"' e. ;i do.
      outstr =. outstr, '"arg',(": i_index),'" : "',(('"';'\"') stringreplace 
;i),'", '
    else.
      outstr =. outstr, '"arg',(": i_index),'" : "',(;i),'", '
    end.
  end.
  outstr, '"msg":"that''s all folks!"}}’
)

TODO: 
action.sh should convert arg2 (the JSON payload) into boxed format using 
‘convert/JSON’

Main.ijs currently expects an ARGV style parameter and just echos it back using 
a string representation for JSON. But really it should expect a JSON value that 
has already been converted into J boxed JSON form by ‘convert/json’
And return the same.

The J addons needed must be downloaded manually to the image build directory. 
This should probably be changed to a ‘wget' in the Docker file so the 
compressed files can be downloaded directly from the JSoftware site thereby 
obtaining the most up to date add-on available. 


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to