Recently I've been doing some web development in Common Lisp (and even getting paid for it!). I must say, I'm quite enjoying it (definitely more than the other language I usually earn my bread with, that shall remain unnamed). I'll be posting more about it soon.
Lately, I've been using Docker to separate project components into containers, each with its own filesystem and isolated environment. I've modified some code I found around the web to create Dockerfiles for current versions of SBCL and CCL, the two popular open source Common Lisp implementations.
They're quite rudimentary in their functionality - they only fetch the current (as of this post) version of Lisp and Quicklisp. I've decided not to put code that starts up SWANK by default - I believe enabling remote REPL access should be a decision of the project that is built on top of those Dockerfiles. Adding SWANK support is very simple though; just run this when you're starting your application:
(ql:quickload :swank)
(setf swank::*LOOPBACK-INTERFACE* "0.0.0.0")
(swank:create-server :port 4005 :dont-close t)
and map SWANK port when doing docker run
:
docker run --name="your-app" -v `pwd`/src:/var/src -p 4005:4005 -ti -d yourname/app
and you can connect to it via M-x slime-connect
straight from your Emacs.
It's actually quite easy to bundle that in your own Dockerfile for your app. For SBCL, it could look like this:
FROM temporal/quicksbcl
ADD ./startup.lisp /tmp/startup.lisp
CMD sbcl --load /tmp/startup.lisp
EXPOSE 4005
Where temporal/quicksbcl
stands for the name you gave for the SBCL container you built and startup.lisp
is the file you use to boot up your application, in which you could put the SWANK start code from above. The code for CCL is very similar, so I'll leave it out as an exercise to the reader :P.
Feel free to use and modify those Docker scripts as you wish. Since I'm not really good at Docker yet, those scripts could likely use some improvements. All issues and pull requests are welcome! And stay tuned for the upcoming posts about Lisp and web development!