6

I'm trying to run the Plutus Pioneer code on a Docker container based on https://hub.docker.com/r/nixos/nix.

I've followed this guide to install Cabal and GHC https://www.reddit.com/r/haskell/comments/dg4dvs/install_ghc_in_25mins_or_ghcjs_in_one_sleep_with/

I haven't been able to get GHCJS installed, though I'm not sure if it is necessary.

Is there any guide on pre-requisites for the Plutus Pioneer Program, ideally with install instructions?

1

2 Answers 2

4

There are instructions on the official input-output-hk/plutus-pioneer-program repo in the exercises chapter here: https://github.com/input-output-hk/plutus-pioneer-program#exercises

I think you may be missing the following step:

Set-up IOHK binary caches How to set up the IOHK binary caches. "If you do not do this, you will end up building GHC, which takes several hours. If you find yourself building GHC, STOP and fix the cache."

As far as I can tell, GHCJS is not necessary, but I haven't tested this.

1
  • I do have the binary caches set up. The instructions in the input-output-hk/plutus-pioneer-program repo assume quite a lot is set up already. This includes but may not be limited to : nix, ghc, cabal and npm. I have installed all these and the Plutus Client is still not working for me. I was hoping for a one page "How to set up an environment from scratch". A ready made docker container would be even better. Commented Jun 22, 2021 at 1:32
2

I am running the Plutus Pioneer code in a nixos/nix based Docker container and it works a treat. I use the nix-shell as recommended in the pioneer program repo and I only needed to set up the IOHK binary caches and install git (using nix) as a prerequisite. I added curl and tmux to make it more user friendly. I use tmux to set up a three pane session containing the Plutus server, the playground GUI and one for interactive cabal. Below is the contents of the Dockerfile I use to buid the image.

FROM nixos/nix

RUN echo "substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/" >> /etc/nix/nix.conf && \
    echo "trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" >> /etc/nix/nix.conf && \
    nix-env --install git && \
    nix-env --install curl && \
    nix-env --install tmux

It is important to map the /nix folder to a data volume for better performance and to keep the size of the running container down. This folder can easily contain a few tens of Gb of data.

I keep the Plutus and Pioneer code repos on the host and map a data volume to bring it into the container:

docker run -it -p 8009:8009 -v hkvb_nixos_plutus:/nix -v $(pwd):/plutus hkvb/nixos.plutus:original sh

This command only exposes the port of the Playground UI. The hkvb/nixos.plutus image was built using the Dockerfile above and is available on Docker Hub.

There is one minor change required in the Plutus code to make the playground accessible from outside the container. This is in the webpack.config.js file of the plutus-playground-client. THe DevServer is only bound to the localhost network interface (of the container). Adding the line

host: "0.0.0.0",

makes the server available external to the container.

[UPDATE 08/08/2021]
I have found out that it is best to start from a freshly cloned (or new copy) of the Plutus repository when changing commits for build. Changing commit on a Plutus repository that was already used for a build often resulted in problems for me, often leading to never ending builds, especially when building the documentation.

2
  • I'm trying to get this work on my MacOS host, but when I run the Dockerfile, the resulting container has no nix commands available on it. I must be missing something, and will have to do some more research about this, but shouldn't the docker image at nixos/nix have nix already set up on it?
    – marcel_g
    Commented Oct 12, 2021 at 9:34
  • I found the issue with this for me: when I build the image, the nix folder is there in the image, but when I run it, mounting the /nix folder as a volume overrides the nix folder from the image, so it has nothing in it. I've now made a new Ubuntu based Dockerfile that sets up Nix, which is very similar to how the Nixos/Nix Dockerfile sets it up on Alpine, but I skip mounting the nix folder to a host volume.
    – marcel_g
    Commented Oct 14, 2021 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.