The purpose of this repository is to manage the Dockerfile
s to build the images at tehnix/ghcjs-docker. This is set up as an automated build repository, so changes here will trigger builds on docker hub.
To use these images, first set up GHCJS in your stack.yaml
,
resolver: lts-9.21
compiler: ghcjs-0.2.1.9009021_ghc-8.0.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.1.9009021_ghc-8.0.2:
url: https://github.com/matchwood/ghcjs-stack-dist/raw/master/ghcjs-0.2.1.9009021.tar.gz
sha1: b1740c3c99e5039ac306702894cd6e58283f4d31
extra-deps: []
The different versions are:
Now, there's a couple of ways to go around using this image. My main advice is to setup a build script, something like this stack-build-docker.sh script.
Add a Dockerfile
,
FROM tehnix/ghcjs-docker:lts-9.21
RUN mkdir -p /src
VOLUME /src
WORKDIR /src
You can then use it by first building it (just has to be done once),
$ docker build .
Sending build context to Docker daemon 626MB
Step 1/4 : FROM tehnix/ghcjs-docker:lts-9.21
...
---> 6ef295b59aaf
Successfully built 6ef295b59aaf
and then you can run your commands like,
$ docker run -v $(pwd):/src -it 6ef295b59aaf stack build
Obviously substituting the image name for the one your build produces. Alternatively tag the ,
$ docker build -t ghcjs:lts-9.21 .
$ docker run -v $(pwd):/src -it $(docker images -q ghcjs:lts-9.21) stack build
$ docker run -v $(pwd):/src -it tehnix/ghcjs-docker:lts-9.21 stack build
One thing to note is that you have to commit your image afterwards, to persist the build.
$ docker -ps a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c59aca6d8672 a00a947b8fd2 "/usr/local/sbin/pid…" 3 minutes ago Exited (143) 9 seconds ago keen_agnesi
...
$ docker commit c59aca6d8672 ghcjs-lts-9.21
Or,
$ docker commit $(docker ps -l -q) ghcjs:lts-9.21
Where docker ps -l -q
gives the latest built container ID.
Ideally, you would make stack
manage the docker image, by having something like,
resolver: lts-9.21
compiler: ghcjs-0.2.1.9009021_ghc-8.0.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.1.9009021_ghc-8.0.2:
url: https://github.com/matchwood/ghcjs-stack-dist/raw/master/ghcjs-0.2.1.9009021.tar.gz
sha1: b1740c3c99e5039ac306702894cd6e58283f4d31
docker:
enable: true
repo: "tehnix/ghcjs-docker" # It will automatically add :lts-x.xx
auto-pull: true
system-ghc: false
Unfortunately, stack
will start looking for GHCJS on the host system, and therefore will not catch that GHCJS has already been built in the container image it's using. I'm suspect this has something to do with setup-info
, but it's not entirely clear to me how to resolve this issue.