Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions wolfram/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN case $(uname -m) in \
FROM --platform=linux/amd64 ${WWE}

ARG WOLFRAM_ENGINE_VERSION=15.0
ARG TOOLKIT_WOLFRAM_VERSION=v1.1.0

ENV LOG_FORMAT="production"

Expand All @@ -30,6 +31,24 @@ WORKDIR /app
# add wstp server to path
ENV PATH=$PATH:/usr/local/Wolfram/WolframEngine/${WOLFRAM_ENGINE_VERSION}/SystemFiles/Links/WSTPServer

# add the shared Wolfram evaluation-function toolkit (JSON comms layer),
# used by all Wolfram-based evaluation functions via PacletDirectoryLoad.
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --branch ${TOOLKIT_WOLFRAM_VERSION} --depth 1 \
https://github.com/lambda-feedback/toolkit-wolfram.git /opt/lambda-feedback/toolkit-wolfram

ENV LF_TOOLKIT_PATH="/opt/lambda-feedback/toolkit-wolfram"

# Every Wolfram evaluation function follows the same shape: an evaluate.m
# and preview.m providing evaluate`EvaluationFunction / preview`PreviewFunction.
# Bootstrap.wl (shipped by toolkit-wolfram, cloned above) is the one fixed
# entry point that wires those into the toolkit's ServeEvaluationFunction --
# evaluation function repos only need to COPY their evaluate.m/preview.m
# into WORKDIR, not their own entry script.
ENV FUNCTION_COMMAND="wolframscript"
ENV FUNCTION_ARGS="-f,/opt/lambda-feedback/toolkit-wolfram/Bootstrap.wl"

# add shimmy
COPY --from=shimmy /shimmy /usr/local/bin/shimmy

Expand Down
19 changes: 14 additions & 5 deletions wolfram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ This is the base image which is intended to be used by evaluation functions writ

## Usage

This image is not meant to be run directly. Instead, it ought to be used as a base image for evaluation functions written in Wolfram Language. The evaluation function should be placed in the `/app` directory.
This image is not meant to be run directly. Instead, it ought to be used as a base image for evaluation functions written in Wolfram Language.

Here is an example of a `Dockerfile` that uses this image as a base:
Every Wolfram evaluation function follows the same shape: an `evaluate.m` and
`preview.m` defining `evaluate\`EvaluationFunction` and
`preview\`PreviewFunction` respectively. This image already wires those into
the shared [`toolkit-wolfram`](https://github.com/lambda-feedback/toolkit-wolfram)
comms layer via `FUNCTION_COMMAND`/`FUNCTION_ARGS` (pointing at
`toolkit-wolfram`'s `Bootstrap.wl`), so a consuming evaluation function repo
only needs to provide those two files:

```Dockerfile
FROM ghcr.io/lambda-feedback/evaluation-function-base/wolfram:latest

COPY ./function.wl /app/function.wl

CMD ["shimmy", "-i", "file", "-c", "wolframscript", "-a", "-f", "-a", "/app/function.wl"]
COPY ./evaluate.m /app/evaluate.m
COPY ./preview.m /app/preview.m
```

A repo that needs custom wiring instead of the standard `evaluate.m`/
`preview.m` convention can still override `FUNCTION_COMMAND`/`FUNCTION_ARGS`
to point at its own entry script.
Loading