Skip to content

10 Gerbil in Docker

You can run Gerbil in docker using our prebuilt containers.

We offer two official docker images based on Alpine Linux:

Alpine was chosen due to the static compilation environment and capabilities it provides.

If you want to build your own container, perhaps based on some other distribution, you can use our Dockerfile.

10.1 Running Gerbil in Docker

docker run -it gerbil/gerbil will invoke the Gerbil repl.

10.2 Building static executable binaries using the gerbilxx image.

Here is an example of building a static binary for a gerbil project.

build.ss

#!/usr/bin/env gxi
;; -*- Gerbil -*-

(import :std/build-script)

(defbuild-script
  '("confluence/client"
	(exe: "confluence/confluence")))

Makefile

PROJECT := confluence

ARCH := $(shell uname -m)
DOCKER_IMAGE := "gerbil/gerbilxx:$(ARCH)"

default: linux-static-docker

build-release:
	/opt/gerbil/bin/gxpkg link $(PROJECT) /src || true
	/opt/gerbil/bin/gxpkg deps -i
    /opt/gerbil/bin/gxpkg build --release $(PROJECT)

linux-static-docker: clean
	docker run -it \
	-e GERBIL_PATH=/src/.gerbil \
	-e USER=$(USER) \
	-v $(PWD):/src:z \
	$(DOCKER_IMAGE) \
	make -C /src build-release

clean:
	rm -rf .gerbil

install:
	mv .gerbil/bin/$(PROJECT) /usr/local/bin/$(PROJECT)

10.3 Building docker images

There are several variations you can build out on docker. We produce ubuntu and fedora images for x86_64 used in the creation of the deb and rpm packages.

Build using custom branch

cd gerbil/docker && make gerbil BRANCH=my-fixup-branch

Building from your own repository

cd gerbil/docker && make gerbil REPO=my-github-user/gerbil