Dockerfile builder
Faber runs whatever toolchains its image contains. Tick the languages you
serve and copy the result: a Dockerfile on top of vgfractal/faber:base (Faber
without compilers) that installs only those toolchains, adds the paths they
need to SANDBOX_READONLY_PATHS, and records them in FABER_TOOLCHAINS so
GET /info can report them. The page keeps your choice in its URL, so you can
share or bookmark it.
Dockerfile
# Faber with C 12.
# Generated from docker/toolchains/catalog.json by the Faber Dockerfile builder.
FROM vgfractal/faber:base
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
libc6-dev \
make \
&& rm -rf /var/lib/apt/lists/*
ENV SANDBOX_READONLY_PATHS=/bin,/lib,/lib64,/usr,/etc/alternatives,/etc/ld.so.cache,/etc/passwd,/etc/group \
FABER_TOOLCHAINS=c@12
# Identifies this build in the step cache. Pass a new value on every build:
# docker build --build-arg FABER_IMAGE_ID="$(date -u +%Y%m%dT%H%M%SZ)" .
ARG FABER_IMAGE_ID=
ENV FABER_IMAGE_ID=${FABER_IMAGE_ID}
Build and run
Recommended limits
| Language | Size | Memory | PIDs | Compile | Run | Task env |
|---|
Before you deploy the image
Section titled “Before you deploy the image”- Build it with the command above, in a directory that holds only the Dockerfile.
- Test every language under the default sandbox profile before relying on
it. Start the image (privileged, as above) and run
API_URL=http://localhost:3000/api/v1 API_KEY=... scripts/toolchain-test.shfrom a checkout of the repository; it runs each language’s example program and checks its output. On a development machine, run it inside the disposable VM withscripts/vm.sh test-toolchainsinstead. - Set
FABER_IMAGE_IDto the image digest or your build ID when the step cache is enabled, so a rebuilt image never replays layers produced by different toolchains. - Pin the base tag to a release in production instead of
base, which moves with every push tomain.
Using the languages
Section titled “Using the languages”- Profiles. The table lists the profile to compile with and the one to
run with. Languages whose programs start threads (Go, the JVM, Node.js) run
under
compile_v2; single-threaded native programs can run under the stricternative_v2. See sandbox profiles. - Task environment. Tasks do not inherit the image’s
ENV. Some toolchains need a writable home or cache directory; send the variables in the “Task env” column in each task’senv. - Limits.
MEMORY_MAXandPIDS_MAXapply to every task of an instance. If one language needs more, every task gets more, and the instance needs more memory per task slot. Serving a heavy runtime and many light ones? Consider separate instances.
A language that is not listed
Section titled “A language that is not listed”Write the Dockerfile by hand on top of the builder’s output: install the
toolchain under a path tasks can see, link its commands into /usr/local/bin
(the sandbox’s PATH does not include the image’s), add any other path it
reads to SANDBOX_READONLY_PATHS, and test it as above. Docker
deployment lists the rules.