I played a bit with the two and came up with my own version, suitable to produce images able to build and host simple Haskell server code. This is no production setup, but will open the door to more fine-tuned experimentation.
Let's jump right into it!
- First of all, here is the source code of a minimal Haskell Warp server I'm going to be hosting: haskell-warp.
-
Secondly, the dockerfile (also contained in the github repository from the previous point):
FROM ubuntu:16.04 MAINTAINER piotr - dot - justyna - at - gmail.com # Install dependencies. RUN apt-get update && \ apt-get install --assume-yes curl gcc libgmp-dev make xz-utils zlib1g-dev # Install Stack. RUN curl --location https://www.stackage.org/stack/linux-x86_64-static > stack.tar.gz && \ tar xf stack.tar.gz && \ cp stack-*-linux-x86_64-static/stack /usr/local/bin/stack && \ rm -f -r stack.tar.gz stack-*-linux-x86_64-static/stack && \ stack --version # Install GHC. WORKDIR /haskell-warp COPY haskell-warp/stack.yaml /haskell-warp RUN stack setup && stack exec -- ghc --version # Build. COPY /haskell-warp /haskell-warp RUN stack build --copy-bins --local-bin-path /usr/local/bin # Run project. ENV HOST 0.0.0.0 ENV PORT 3000 EXPOSE 3000 CMD /usr/local/bin/haskell-warp-exe
-
Now it's time to build my image (this will take a good while):
$ docker build -t haskell-ubuntu:16.04 .
-
Next, time to create a running container from the image:
docker run --name haskell-warp -d -p 80:3000 haskell-ubuntu:16.04
- Finally, time to test the code we've just deployed:
Keep hacking!
Piotr
No comments:
Post a Comment