Skip to content

DevContainer OCaml development environment for VS Code, Codespaces, and any editor

Notifications You must be signed in to change notification settings

tarides/ocaml-devcontainer

Repository files navigation

OCaml 5.4 DevContainer

Production-ready OCaml development environment for VS Code, Codespaces, and any editor.

Open in GitHub Codespaces

Features

  • OCaml 5.4 with standard and ThreadSanitizer variants
  • Full toolchain: dune, LSP, merlin, ocamlformat, utop
  • Testing: ounit2, ppx_expect, qcheck, bisect_ppx (coverage)
  • Profiling: landmarks, memtrace, olly
  • Multi-editor: VS Code, Vim, Emacs, Neovim, Claude Code
  • Zero setup: Works instantly in GitHub Codespaces

Quick Start

GitHub Codespaces (Instant)

Click "Open in GitHub Codespaces" above. Ready in ~2 minutes.

Local (VS Code)

git clone https://github.com/tarides/ocaml-devcontainer.git
code ocaml-devcontainer
# Click "Reopen in Container" when prompted

Local (Any Editor)

npm install -g @devcontainers/cli
git clone https://github.com/tarides/ocaml-devcontainer.git
cd ocaml-devcontainer
devcontainer up --workspace-folder .

# Use your preferred editor
devcontainer exec --workspace-folder . vim examples/hello/hello.ml
devcontainer exec --workspace-folder . dune build

Documentation

Guide Description
DEVCONTAINER.md Quick start overview
docs/SETUP-CODESPACES.md GitHub Codespaces setup
docs/SETUP-DEVCONTAINER-EXEC.md Primary local workflow
docs/SETUP-VSCODE.md VS Code integration
docs/SETUP-ADVANCED.md TRAMP, Neovim, customization

OCaml Switches

Two switches are pre-configured with identical tools:

Switch Description
5.4.0 Standard OCaml 5.4 (default)
5.4.0+tsan ThreadSanitizer for race detection

Switch between them:

opam switch 5.4.0+tsan
eval $(opam env)

Project Structure

.devcontainer/           # Pre-built image config (fast startup)
.devcontainer-from-scratch/  # Local build config
base/                    # Base image (compilers)
dev/                     # Dev image (tools)
examples/                # Sample projects
test/                    # Integration tests
docs/                    # Setup guides

Building from Source

To build the Docker images locally:

# Required: reduce ASLR entropy for TSan compilation
sudo sysctl -w vm.mmap_rnd_bits=28

# Build images
docker build -t ocaml-5.4-base base/
docker build -t ocaml-5.4-dev dev/

The vm.mmap_rnd_bits=28 setting is required for the ThreadSanitizer switch to compile. See google/sanitizers#1716 for details.

For Tutorial Authors

This environment is designed for OCaml tutorials and workshops. Create a tutorial-specific image:

FROM ghcr.io/tarides/ocaml-5.4-dev:latest
RUN opam install -y lwt eio  # Add your packages
COPY exercises/ /home/vscode/exercises/

License

MIT

About

DevContainer OCaml development environment for VS Code, Codespaces, and any editor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •