This blog is implemented in Pharo and is the natural choice for my Docker
example application. I already have a Smalltalk snippet to load this blog's
code and its dependencies into a pristine Pharo image, so I'll be using
that. Also, as a matter of course, I build the Pharo VM from source, and my
VM installation also contains self-built shared libraries like libsqlite.so
Outside of Docker, prepare a custom Pharo image:
gofaro is a simple shell script which purpose is to make sure the Pharo VM
loads my custom shared libraries, co-located with the standard VM files, at
loadSCMS1.st looks like this:
Before describing my Dockerfile, here are my conventions for inside the
VM goes into /pkg/vm.
Application artifacts including the image and changes files go into /pkg/image.
For this blog application, the blog's content is in /pkg/cms.
Starting with Ubuntu 18.04, install libfreetype6. The other lines are
copied from Torsten's tutorial.
Next, install the Pharo VM.
Now copy over the prepared Pharo image.
Finally, set the Docker container running. Here we create a UID/GID pair to
run the application. Said UID owns the mutable Pharo files in /pkg/image
and also the /pkg/image directory itself, in case the application needs to
create other files such as SQLite databases.
runSCMS1.st runs the blog application. In my current non-Dockerized
installation, the runSCMS1.st-equivalent snippet is in a workspace; for
Docker, to become DevOps/agile/CI/CD buzzwords-compliant, this snippet is
run from the command line. This is one Dockerization adaptation I had to
make to my application.
Now we build the Docker image.
The Docker image has been created, but it is not ready to run yet, because
the web content is not in the image. I'll put the content in a Docker
volume. Below, the first -v
mounts my host's content directory into /tmp/webcontent in the container;
the second -v mounts the volume smdw-content into /pkg/cms in the
container; I'm running the busybox image to get a shell prompt; and within
the container I copy the web content from the source to the destination.
Finally, run the Docker image, taking care to mount the volume
smdw-content, now with this blog's content:
Verified with a web browser. This works on my computer. :-)