Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@timbod7
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timbod7/54c95ae537f01461bac3 to your computer and use it in GitHub Desktop.
Save timbod7/54c95ae537f01461bac3 to your computer and use it in GitHub Desktop.
Setup an Amazon Linux EC2 instance to run codeworld
# Update and install basic dependencies
sudo yum update -y
sudo yum install -y git
sudo yum install -y zlib-devel
sudo yum install -y ncurses-devel
# Needed for ghcjs-boot --dev
sudo yum install -y patch
sudo yum install -y autoconf
sudo yum install -y automake
mkdir downloads
mkdir build
DOWNLOADS=$HOME/downloads
BUILD=$HOME/build
PREFIX=$HOME
mkdir $PREFIX/bin
export PATH=$PREFIX/bin:$PATH
# Install GHC 7.8, since it's required for GHCJS.
sudo yum install -y gcc
sudo yum install -y gmp-devel
(cd $DOWNLOADS && wget http://www.haskell.org/ghc/dist/7.8.2/ghc-7.8.2-x86_64-unknown-linux-centos65.tar.bz2)
(cd $BUILD && tar -xjf $DOWNLOADS/ghc-7.8.2-x86_64-unknown-linux-centos65.tar.bz2)
(cd $BUILD/ghc-7.8.2 && ./configure --prefix $PREFIX)
(cd $BUILD/ghc-7.8.2 && make install)
# install node (seems to be necessary for ghcjs-boot)
sudo yum install -y gcc-c++
sudo yum install -y openssl-devel
(cd $DOWNLOADS && wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz)
(cd $BUILD && tar -zxf $DOWNLOADS/node-v0.10.29.tar.gz)
(cd $BUILD/node-v0.10.29 && ./configure --prefix=$PREFIX)
(cd $BUILD/node-v0.10.29 && make)
(cd $BUILD/node-v0.10.29 && make install)
# Install all the dependencies for cabal
fromHackage() {
(cd $DOWNLOADS && wget https://hackage.haskell.org/package/$1-$2/$1-$2.tar.gz)
(cd $BUILD && tar -xzf $DOWNLOADS/$1-$2.tar.gz)
(cd $BUILD/$1-$2 && runghc $3 configure --prefix=$PREFIX)
(cd $BUILD/$1-$2 && runghc $3 build)
(cd $BUILD/$1-$2 && runghc $3 install)
}
fromHackage zlib 0.5.4.1 Setup.hs
fromHackage stm 2.4.3 Setup.hs
fromHackage random 1.0.1.1 Setup.hs
fromHackage mtl 2.1.3.1 Setup.hs
fromHackage text 1.1.1.3 Setup.lhs
fromHackage parsec 3.1.5 Setup.hs
fromHackage network 2.5.0.0 Setup.hs
fromHackage HTTP 4000.2.17 Setup.lhs
# Get a patched version of cabal (https://github.com/ghcjs/cabal) and
# then git checkout ghcjs to switch to the GHCJS branch, and finally
# cabal install both the Cabal and cabal-install packages.
fromLocal() {
(cd $1 && runghc $2 configure --prefix=$PREFIX)
(cd $1 && runghc $2 build)
(cd $1 && runghc $2 install)
}
git clone -b ghcjs https://github.com/ghcjs/cabal.git
(cd cabal && git checkout f70ed6277942c74bdd68f63e2b0694d57dcb8606) # Current ghcjs/HEAD doesn't build
fromLocal cabal/Cabal Setup.hs
fromLocal cabal/cabal-install Setup.hs
cabal update
# Get GHCJS itself (https://github.com/ghcjs/ghcjs) and cabal install.
cabal install --prefix=$PREFIX alex
cabal install --prefix=$PREFIX happy
git clone https://github.com/ghcjs/ghcjs-prim.git
(cd ghcjs-prim && git checkout 54d2ce21d713fe052dcad8e815e13c13585a4262)
(cd ghcjs-prim && cabal install)
git clone https://github.com/ghcjs/ghcjs.git
(cd ghcjs && git checkout e7d77288517e202708187fe6bcca2eead7aefa6c)
(cd ghcjs && cabal install --prefix=$PREFIX)
# Bootstrap ghcjs
ghcjs-boot --dev
# Check out ghcjs-dom (https://github.com/ghcjs/ghcjs-dom) and install it
git clone https://github.com/ghcjs/ghcjs-dom.git
(cd ghcjs-dom && git checkout 1fb18971dff6a793de27d95b4561411ff0f9c722)
(cd ghcjs-dom && cabal install --ghcjs)
# Check out ghcjs-canvas (https://github.com/ghcjs/ghcjs-canvas) and install it
git clone https://github.com/ghcjs/ghcjs-canvas
(cd ghcjs-canvas && git checkout 73a09bfc538b61f05299f58dedb5f3010437efcc)
(cd ghcjs-canvas && cabal install --ghcjs)
# Install the codeworld-base package
git clone https://github.com/google/codeworld.git
(cd codeworld/codeworld-base && cabal install --ghcjs)
# Build codeworld-server from this project: cd codeworld-server && cabal build
(cd codeworld/codeworld-server && cabal install --dependencies-only)
(cd codeworld/codeworld-server && cabal build)
# Get a Google API key, and store it in web/clientId.txt.
echo MYGOOGLEAPIKEY >codeworld/codeworld-server/web/clientId.txt
# Run the server: cd codeworld-server && ./run.sh 8080.
(cd codeworld/codeworld-server && ./run.sh 8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment