This repo provides a Docker container that includes common Haskell build tools so that you can start developing and building your Haskell app right away without setting up a local dev environment.
Tools included in containser:
- GHC (ghcup recommended version)
- cabal (ghcup recommended version)
- stack (ghcup recommended version)
- haskell language server (ghcup recommended version)
- git and scm_breeze
- Vim (with optional Vim IDE setup script)
I have some prebuilt images uploaded to DockerHub.
Decide what ghc version you want, and pull it down by running:
docker pull bjing/haskell-dev-container:<tag>
You can also build the container image yourself.
-
check out this repo locally:
git clone https://github.com/bjing/haskell-dev-container.git
-
Edit scripts/install_haskell.env to specify versions of the tools you'd like to install
-
Build the image by running:
./build.sh
This will generate a docker image haskell-dev-container:latest
.
Here I assume you're using a prebuilt docker image on DockerHub.
Go to the Haskell project you're working on in the terminal:
cd my-haskell-project
Then start the dev container and mount the project into it:
code
is a pre-created user in the container:
docker run -d --rm --name haskell-dev-container -v .:/home/code/app bjing/haskell-dev-container:latest
Get into the container by running:
docker exec -it haskell-dev-container bash
Now you're inside the container with the project directory mounted. You can use
either cabal
or stack
depending on what you're using to build your project.
For example:
stack build
Install extension DevContainers.
Copy directory .devcontainer to your Haskell project's root directory. Change the docker image tag in .devcontainer/devcontainer.json as you see fit.
Bring up Command palette, and run Dev Containers: Open Folder in Container
.
Now you can build the project in VSCode's terminal using either cabal
or stack
.
If you need tools that are not provided by the container,
simply installed it through Debian's apt
package manager, e.g.
sudo apt install <package_name>
Since the container user code
has sudo privilege, you can
install any tools you want.
The container image provides setup script for VIM Haskell IDE.
Simply run the setup script in /home/code/install:
cd ~/install
./setup_vim.sh