Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active December 3, 2022 16:45
Show Gist options
  • Save rwcitek/9ea148a86ac2ac2372d4f2f62c1abe06 to your computer and use it in GitHub Desktop.
Save rwcitek/9ea148a86ac2ac2372d4f2f62c1abe06 to your computer and use it in GitHub Desktop.
Installing haskell in an Ubuntu Docker container
# These commands were run using the bash shell on Debian 11 in the Linuv Dev Env on a Chromebook
# make sure no haskell instances exist
docker container stop haskell ; docker container rm haskell ; sleep 2
# run an Ubuntu container in the background
docker container run -d --name haskell ubuntu:22.04 sleep inf
# install utilities and haskell
<<'eof' docker container exec -i haskell /bin/bash
DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y vim tree curl jq git file
apt-get install -y ghc
mkdir -p /tmp/haskell
eof
# at this point one could commit the container to an image
# ... or convert the above commands to a Dockerfile to build an image
# for fun, download some haskell code
<<'eof' docker container exec -i -w /tmp/haskell haskell /bin/bash
curl -s https://www.schoolofhaskell.com/tutorial-raw/6170/e6ed3e6f43459bb134948a6053e1000237a06aa2 |
awk '
BEGIN { in_code = 0 } ;
/^###/ {
gsub(/^#+ */,"") ;
gsub(/ +/, ".") ;
name = tolower($0) ".hs" ;
} ;
/^```/ && in_code {
print "== To: " name
lines = lines "\n"
print lines > name
lines = ""
in_code = !in_code ;
next ;
} ;
/^```/ && !in_code {
in_code = !in_code ;
next ;
} ;
in_code {
lines = lines "\n" $0
};
'
eof
# exec into an interactive container
docker container exec -it -w /tmp/haskell haskell /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment