As part of my attempt to make miso-isomorphic-stack as smooth an experience as possible, I've made a couple of docker images with GHCJS and some newer stack versions (repo here and hub here), based on these distributions. You can see in the repo how you can use them, and maybe this script for how to integrate that more nicely in your process.
So, 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 suspect this has something to do with setup-info, but it's not entirely clear to me how to resolve this issue.
I'm hoping someone here might know a bit more what goes on with stack, and how the compiler is handled.
The images themselves are fairly simple, they just install GHCJS in them, meaning you don't have to spend hours building GHCJS yourself, with whatever issues that bring up, and can get started quickly trying out GHCJS.
Trying with the suggestion from @mgsloan fails with the following,
No information found for ghcjs-0.2.1.9009021_ghc-8.0.2.
Supported versions for OS key 'source': GhcjsVersion 0.1.0.20150924 7.10.2
With the full build log of stack -v build:
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
2018-04-24 12:56:42.195877: [debug] Loading project config file frontend/stack.yaml
@(Stack/Config.hs:868:13)
2018-04-24 12:56:42.205781: [debug] Run process: /usr/local/bin/docker --version
@(System/Process/Log.hs:37:3)
2018-04-24 12:56:42.559527: [debug] Process finished in 353ms: /usr/local/bin/docker --version
@(System/Process/Log.hs:44:3)
2018-04-24 12:56:42.559917: [debug] Run process: /usr/local/bin/docker inspect tehnix/ghcjs-docker:lts-9.21
@(System/Process/Log.hs:37:3)
2018-04-24 12:56:42.643497: [debug] Process finished in 83ms: /usr/local/bin/docker inspect tehnix/ghcjs-docker:lts-9.21
@(System/Process/Log.hs:44:3)
2018-04-24 12:56:42.657949: [debug] Run process: /usr/local/bin/docker create --net=host -e STACK_IN_CONTAINER=1 -e STACK_ROOT=/Users/christiankjaerlaustsen/.stack -e STACK_PLATFORM_VARIANT=dkb61b2dc4e76119fbba7cceb60d5ffa49 -e HOME=/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home -e PATH=/opt/host/bin:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home/.local/bin:/root/.cabal/bin:/root/.local/bin:/opt/ghc/8.2.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -e PWD=/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack -v /Users/christiankjaerlaustsen:/Users/christiankjaerlaustsen -v /Users/christiankjaerlaustsen/.stack:/Users/christiankjaerlaustsen/.stack -v /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend -v /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home -w /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack -e USER=christiankjaerlaustsen -e SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners -v /private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners:/private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners -v /Users/christiankjaerlaustsen/.stack/programs/x86_64-linux/stack-1.6.3/stack:/opt/host/bin/stack -t -i tehnix/ghcjs-docker:lts-9.21 /opt/host/bin/stack --internal-re-exec-version=1.6.3 --internal-docker-entrypoint "DockerEntrypoint {deUser = Just (DockerUser {duUid = 501, duGid = 20, duGroups = [20,12,61,79,80,81,98,702,33,100,204,250,395,398,399,701], duUmask = 18})}" --stack-yaml=frontend/stack.yaml -v build
@(System/Process/Log.hs:37:3)
2018-04-24 12:56:42.909494: [debug] Process finished in 248ms: /usr/local/bin/docker create --net=host -e STACK_IN_CONTAINER=1 -e STACK_ROOT=/Users/christiankjaerlaustsen/.stack -e STACK_PLATFORM_VARIANT=dkb61b2dc4e76119fbba7cceb60d5ffa49 -e HOME=/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home -e PATH=/opt/host/bin:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home/.local/bin:/root/.cabal/bin:/root/.local/bin:/opt/ghc/8.2.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -e PWD=/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack -v /Users/christiankjaerlaustsen:/Users/christiankjaerlaustsen -v /Users/christiankjaerlaustsen/.stack:/Users/christiankjaerlaustsen/.stack -v /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend -v /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home:/Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home -w /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack -e USER=christiankjaerlaustsen -e SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners -v /private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners:/private/tmp/com.apple.launchd.D8v3WjTyAg/Listeners -v /Users/christiankjaerlaustsen/.stack/programs/x86_64-linux/stack-1.6.3/stack:/opt/host/bin/stack -t -i tehnix/ghcjs-docker:lts-9.21 /opt/host/bin/stack --internal-re-exec-version=1.6.3 --internal-docker-entrypoint "DockerEntrypoint {deUser = Just (DockerUser {duUid = 501, duGid = 20, duGroups = [20,12,61,79,80,81,98,702,33,100,204,250,395,398,399,701], duUmask = 18})}" --stack-yaml=frontend/stack.yaml -v build
@(System/Process/Log.hs:44:3)
2018-04-24 12:56:42.910090: [debug] Creating process: /usr/local/bin/docker start -a -i 791fe386a759de5b23f7bf62a2cca15bdfa540287528024ec9931c4c69b4d913
@(System/Process/Log.hs:22:3)
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
2018-04-24 10:56:48.844354: [debug] Loading project config file frontend/stack.yaml
@(Stack/Config.hs:868:13)
2018-04-24 10:56:48.856002: [debug] Run process: /usr/sbin/groupadd -o --gid 20 stack
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.887487: [debug] Process finished in 31ms: /usr/sbin/groupadd -o --gid 20 stack
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.890291: [debug] Run process: /usr/sbin/useradd -oN --uid 501 --gid 20 --home /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home stack
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.929204: [debug] Process finished in 38ms: /usr/sbin/useradd -oN --uid 501 --gid 20 --home /Users/christiankjaerlaustsen/GitHub/Tehnix/miso-isomorphic-stack/frontend/.stack-work/docker/_home stack
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.929360: [debug] Run process: /usr/sbin/groupadd -o --gid 20 group20
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.938691: [debug] Process finished in 9ms: /usr/sbin/groupadd -o --gid 20 group20
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.938807: [debug] Run process: /usr/sbin/groupadd -o --gid 12 group12
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.952149: [debug] Process finished in 13ms: /usr/sbin/groupadd -o --gid 12 group12
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.952316: [debug] Run process: /usr/sbin/groupadd -o --gid 61 group61
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.977534: [debug] Process finished in 25ms: /usr/sbin/groupadd -o --gid 61 group61
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.977670: [debug] Run process: /usr/sbin/groupadd -o --gid 79 group79
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:48.991099: [debug] Process finished in 13ms: /usr/sbin/groupadd -o --gid 79 group79
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:48.991271: [debug] Run process: /usr/sbin/groupadd -o --gid 80 group80
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.006803: [debug] Process finished in 14ms: /usr/sbin/groupadd -o --gid 80 group80
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.006984: [debug] Run process: /usr/sbin/groupadd -o --gid 81 group81
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.020884: [debug] Process finished in 13ms: /usr/sbin/groupadd -o --gid 81 group81
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.021037: [debug] Run process: /usr/sbin/groupadd -o --gid 98 group98
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.030441: [debug] Process finished in 9ms: /usr/sbin/groupadd -o --gid 98 group98
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.030551: [debug] Run process: /usr/sbin/groupadd -o --gid 702 group702
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.040424: [debug] Process finished in 9ms: /usr/sbin/groupadd -o --gid 702 group702
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.040532: [debug] Run process: /usr/sbin/groupadd -o --gid 33 group33
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.051412: [debug] Process finished in 10ms: /usr/sbin/groupadd -o --gid 33 group33
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.051632: [debug] Run process: /usr/sbin/groupadd -o --gid 100 group100
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.061282: [debug] Process finished in 8ms: /usr/sbin/groupadd -o --gid 100 group100
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.061803: [debug] Run process: /usr/sbin/groupadd -o --gid 204 group204
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.074834: [debug] Process finished in 12ms: /usr/sbin/groupadd -o --gid 204 group204
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.075014: [debug] Run process: /usr/sbin/groupadd -o --gid 250 group250
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.085177: [debug] Process finished in 9ms: /usr/sbin/groupadd -o --gid 250 group250
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.085324: [debug] Run process: /usr/sbin/groupadd -o --gid 395 group395
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.093166: [debug] Process finished in 7ms: /usr/sbin/groupadd -o --gid 395 group395
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.093303: [debug] Run process: /usr/sbin/groupadd -o --gid 398 group398
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.101006: [debug] Process finished in 7ms: /usr/sbin/groupadd -o --gid 398 group398
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.101161: [debug] Run process: /usr/sbin/groupadd -o --gid 399 group399
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.109153: [debug] Process finished in 7ms: /usr/sbin/groupadd -o --gid 399 group399
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.109306: [debug] Run process: /usr/sbin/groupadd -o --gid 701 group701
@(System/Process/Log.hs:37:3)
2018-04-24 10:56:49.117319: [debug] Process finished in 7ms: /usr/sbin/groupadd -o --gid 701 group701
@(System/Process/Log.hs:44:3)
2018-04-24 10:56:49.119055: [debug] Decoding build plan from: /Users/christiankjaerlaustsen/.stack/build-plan/lts-9.21.yaml
@(Stack/Snapshot.hs:150:5)
2018-04-24 10:56:49.119212: [debug] Trying to decode /Users/christiankjaerlaustsen/.stack/build-plan-cache/lts-9.21.cache
@(Data/Store/VersionTagged.hs:66:5)
2018-04-24 10:56:49.132586: [debug] Success decoding /Users/christiankjaerlaustsen/.stack/build-plan-cache/lts-9.21.cache
@(Data/Store/VersionTagged.hs:70:13)
2018-04-24 10:56:49.133008: [debug] Getting system compiler version
@(Stack/Setup.hs:387:17)
No information found for ghcjs-0.2.1.9009021_ghc-8.0.2.
Supported versions for OS key 'source': GhcjsVersion 0.1.0.20150924 7.10.2
2018-04-24 12:56:46.033052: [debug] Run process: /usr/local/bin/docker rm -f 791fe386a759de5b23f7bf62a2cca15bdfa540287528024ec9931c4c69b4d913
@(System/Process/Log.hs:37:3)
2018-04-24 12:56:46.109114: [debug] Process finished in 75ms: /usr/local/bin/docker rm -f 791fe386a759de5b23f7bf62a2cca15bdfa540287528024ec9931c4c69b4d913
@(System/Process/Log.hs:44:3)
I guess, if we go back to the basics, what I'm really asking about is, where/how does stack find GHC inside the docker image, and how can I specify the path to GHCJS?
So, currently, the Dockerfiles that make this image are fairly simple. Take e.g. the one to build GHCJS for lts-9.21,
FROM fpco/stack-build:lts-11.5
# Install node.js for GHCJS.
RUN curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - \
&& apt-get update \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# Set up GHCJS.
COPY src /tmp/setup-ghcjs
RUN cd /tmp/setup-ghcjs \
&& stack setup --system-ghc \
&& rm -rf /tmp/setup-ghcjs
RUN mkdir -p /src
VOLUME /src
WORKDIR /src
What this does is
fpco/stack-build:lts-11.5 stack as a base layer, because it contains cabal, stack, etc. Now, what I imagined would happen was that stack's docker support would pick up this ghcjs-0.2.1.9009021_ghc-8.0.2 compiler when using the image, but that doesn't seem to happen. The image itself works with e.g. docker run -v $(pwd):/src -it tehnix/ghcjs-docker:lts-9.21 stack build.
In other words: How do I make the GHCJS installed compiler discoverable for stack's docker support?
Not sure how much this usecase has been tested so it's quite possible that it doesn't directly work. One thing I noticed is that you have compiler-check: match-exact. While in a way it's good to have this, it also means that when you ask the ghcjs binary to report its version it will need to yield the exact version number you have specified. A lot of the time these binaries unfortunately are not built with the 9009021 portion of the version number.
Also, you have system-ghc: false which means that stack will not use compilers it finds in the environment, and will only use compilers it has installed. The opposite of what you want! How about trying something like this (I haven't tested this):
resolver: lts-9.21
compiler: ghcjs-0.2.1.9009021_ghc-8.0.2
compiler-check: newer-minor
docker:
enable: true
repo: "tehnix/ghcjs-docker" # It will automatically add :lts-x.xx
auto-pull: true
system-ghc: true
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 don't think this should happen. If it looks for a system ghcjs, it should be done from within the container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With