Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Scheme code with multiple implementations using Docker #74

Open
Retropikzel opened this issue Feb 27, 2025 · 0 comments
Open

Running Scheme code with multiple implementations using Docker #74

Retropikzel opened this issue Feb 27, 2025 · 0 comments

Comments

@Retropikzel
Copy link

Problem

You want to write portable code and to test it with multiple implementations. However installing them can be cumbersome and time consuming.

Solution

Running the code in a container using Docker.

Running a script

We mount the current working directory inside the container to /workdir and run file called test.scm. Replace the SCHEME_NAME with the name of the Scheme you want to use, for example "guile". And replace SCHEME_GOMMAND with command you want to run, for example "guile".

docker run -v "$PWD:/workdir" -it schemers/SCHEME_NAME bash -c "cd /workdir && SCHEME_COMMAND test.scm"

If you also need to install some packages inside the container it is better to create a Dockerfile and pass the implementation name as argument. Build it and then run container using the built image.

Here is and example of such Dockerfile in which Scheme implementation is passed as and argument. Then we install the packages we need, just curl here for example. Then we set the workdir inside the Dockerfile so we dont need to set it in the command.

ARG SCHEME=
FROM schemers/${SCHEME}
RUN apt-get update && apt-get install -y curl
WORKDIR /workdir

Then we build it using tag my-scheme and run it. Just like previously replace SCHEME_NAME and SCHEME_COMMAND with implementation and command you want.

docker build . --build-arg SCHEME=SCHEME_NAME --tag=my-scheme
docker run -v "$PWD:/workdir" my-scheme bash -c "SCHEME_COMMAND test.scm"

Opening a REPL

See https://containers.scheme.org/.

Notes

  • Windows
    • You might need to replace the current directory environment variable, $PWD, with %cd%.
  • Containers and tags

Credit: @Retropikzel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant