Skip to content

Instantly share code, notes, and snippets.

@ariesshrimp
Last active May 7, 2017 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariesshrimp/038fe86e9c5128386d4f144f1d31c7f3 to your computer and use it in GitHub Desktop.
Save ariesshrimp/038fe86e9c5128386d4f144f1d31c7f3 to your computer and use it in GitHub Desktop.
A Dockerfile for working through Real World Ocaml https://github.com/realworldocaml/book
# See https://hub.docker.com/r/ocaml/opam/
FROM ocaml/opam
# Get core set up
RUN opam depext -i core
# Do some extra stuff to make cryptokit happy
RUN opam depext conf-zlib.1 && opam depext conf-gmp.1 && opam install cryptokit
# Install all the packages the book uses, including the utop REPL
RUN opam install utop async yojson core_extended core_bench cohttp async_graphics menhir
# Tell utop how to boot up with all the important functions you want
RUN echo '#use "topfind";; #thread;; #camlp4o;; #require "core.top";; #require "core.syntax";; open Core.Std' > ~/.ocamlinit
@ariesshrimp
Copy link
Author

ariesshrimp commented May 7, 2017

To get started:

$ git clone https://gist.github.com/038fe86e9c5128386d4f144f1d31c7f3.git # this gist
# Builds on the https://hub.docker.com/r/ocaml/opam-dev/ commands
$ docker build -t ocaml-core .
$ docker run -ti ocaml-core bash

I also recommend mounting a local directory where you can write all your fancy new Ocaml in your preferred editor, but give Docker access to them to build and run:

$ mkdir ~/real-world-ocaml
# mounts your local machine directory to /real-world-ocaml in your container.
# See https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume
$ docker run -ti ocaml-core bash -v ~/real-world-ocaml:/real-world-ocaml 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment