Add an elm
alias (you probably want to add this to your .bashrc
or similar):
alias elm='docker run -it --rm -v "$(pwd):/code" -w "/code" -e "HOME=/tmp" -u $UID:$GID -p 8000:8000 codesimple/elm:0.19'
Then use the alias to run the elm tools from the container as you would normally:
elm make
elm reactor -a 0.0.0.0
elm repl
...
(You will usually need to use the -a 0.0.0.0
option when running elm reactor
so that you can access it from outside of the container).
The current directory is mounted into the container so that the elm tools can locate your project files
and write out elm.js
and the elm-stuff
directory.
Port 8000 is published to the host to allow this to be used when running elm reactor
.
Change the -p
setting if you want to map this to a different port or disable it.
HOME
is set to /tmp
in the container so that the .elm
directory generated by the elm tools is placed there
and discarded. If you want to share .elm
between runs you could set it to a directory that you have
mounted a volume or host directory at.
If you run elm reactor
on an uncompiled project, you may get errors along the lines of:
elm-make: elm-stuff/packages/evancz/virtual-dom/2.1.0/src/VirtualDom.elm: hGetContents: invalid argument (invalid byte sequence)
elm-make: thread blocked indefinitely in an MVar operation
This can generally be avoided by running elm make
on the project before you run elm reactor
(or after to fix it).
To use a different version of the Elm tools just change the version number in the command above (after codesimple/elm:
).
The following versions are currently supported:
- 0.15.1
- 0.16
- 0.17
- 0.18
- 0.19
- The
elm repl
for Elm 0.17 seems to be missing the coloured output that was present in Elm 0.16 (although error messages fromelm make
do appear in colour). I'm not sure if this is an issue with the build or with the Elm source. - If you experience permissions errors and are running OS X and/or docker machine, see [issue 2] (#2).