Skip to content
/ haskell-dev-base Public template

A standard dev container for Haskell with PostgreSQL database

Notifications You must be signed in to change notification settings

ivelten/haskell-dev-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

haskell-dev-base

A dev container template for Haskell development with PostgreSQL.

What's included

Component Version
GHC 9.6.7
Cabal 3.10.3.0
Haskell Language Server (HLS) 2.12.0.0
PostgreSQL 18.2

Shell: Zsh (default)

System tools: build-essential, curl, git, pkg-config, libffi-dev, libgmp-dev, libpq-dev, libssl-dev, zlib1g-dev, direnv, socat, procps, postgresql-client

VS Code extensions installed automatically:

Prerequisites

Using this template

  1. Click Use this template on GitHub to create a new repository from this template.
  2. Clone your new repository and open it in VS Code.
  3. When prompted, click Reopen in Container (or run the command Dev Containers: Reopen in Container).
  4. The container will build and run the post-creation setup automatically. This may take several minutes on first build.

Database

A PostgreSQL 18.2 instance runs as a companion service (db) in Docker Compose.

Setting Value
Host db
Port 5432 (also forwarded to localhost)
Database db
User postgres
Password postgres

You can connect from inside the container using psql:

psql -h db -U postgres -d db

Or use the SQLTools extension — a pre-configured connection named PostgreSQL - Local is available in the sidebar.

Note: These are local development credentials. Do not use them in production.

Project structure

.
├── .devcontainer/
│   ├── devcontainer.json   # Dev container configuration
│   ├── docker-compose.yml  # App + PostgreSQL services
│   ├── Dockerfile          # Haskell toolchain setup
│   └── post-create.sh      # Post-creation setup script
├── .vscode/
│   └── settings.json       # SQLTools connection + editor settings
├── .editorconfig           # Consistent editor formatting rules
└── .gitignore              # Haskell, Cabal, and VS Code ignores

Customising the template

Changing GHC or HLS versions: Update the version variables in .devcontainer/Dockerfile and update the versions mentioned in .devcontainer/post-create.sh welcome message accordingly.

Changing Cabal version: Update BOOTSTRAP_HASKELL_CABAL_VERSION in .devcontainer/Dockerfile.

Adding Cabal packages as dependencies: Create a cabal.project and .cabal package file at the root of the repository after cloning the template.

Using direnv for per-project environment variables: Add a .envrc file to the project root. direnv is pre-installed and hooked into both Bash and Zsh.