GHCi demo (x86_64)

Example of running GHCi (x86_64) on browser using container2wasm.

Terminal

[launch ENTRYPOINT] [launch shell (sh)] [disable networking]

It can take some time to load and start the container.

Example

Running the following in the container will get the contents of the demo page over HTTP.

:!curl https://ktock.github.io/container2wasm-demo/index.html

Note

Container can perform HTTP(S) networking via the HTTP(S) proxy running on the browser. In the container, http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY are pre-configured to the proxy's address (http://192.168.127.253:80). The proxy (+ networking stack) run on browser, relying on the browser's Fetch API. So out-of-browser proxy service is NOT used. HTTPS connection is terminated at the proxy and relies on Fetch API for re-encryption so the certificate for the proxy is configured as SSL_CERT_FILE=/.wasmenv/proxy.crt in the container.

The proxy is experimental and has limitations:

Please see also container2wasm repo for the details and other less-restricted networking methods (e.g. WebSocket + out-of-browser networking stack).

Tested on Google Chrome 116.0.5845.187. More info including docs and source code is available from container2wasm repo. This page is served from container2wasm-demo repo as GitHub Pages.

Source Container Image

FROM debian:buster-slim

ENV LANG C.UTF-8

# haskell dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        # ca-certificates \
        curl \
        # dpkg-dev \
        # git \
        gcc \
        # gnupg \
        g++ \
        libc6-dev \
        libffi-dev \
        libgmp-dev \
        libnuma-dev \
        libtinfo-dev \
        make \
        netbase \
        xz-utils \
        zlib1g-dev && \
    rm -rf /var/lib/apt/lists/*

ARG GHC=9.10.1

RUN set -eux; \
    cd /tmp; \
    ARCH="x86_64"; \
    GHC_URL="https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-$ARCH-deb10-linux.tar.xz"; \
    curl -sSLk "$GHC_URL" -o ghc.tar.xz; \
    tar xf ghc.tar.xz; \
    cd "ghc-$GHC-$ARCH-unknown-linux"; \
    ./configure --prefix "/opt/ghc/$GHC"; \
    make install; \
    # remove profiling support to save space
    find "/opt/ghc/$GHC/" \( -name "*_p.a" -o -name "*.p_hi" \) -type f -delete; \
    \
    # remove static libaries and interface files to save space
    find "/opt/ghc/$GHC/" \( -name "*.a" -o -name "*.hi" \) -type f -delete; \
    \
    # remove docs to save space
    rm -rf "/opt/ghc/$GHC/share/doc"; \
    \
    rm -rf /tmp/*; \
    "/opt/ghc/$GHC/bin/ghc" --version

ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/${GHC}/bin:$PATH

CMD ["ghci"]

Back to top