Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-haskell micro? #142

Open
PiotrJustyna opened this issue Dec 6, 2024 · 1 comment
Open

docker-haskell micro? #142

PiotrJustyna opened this issue Dec 6, 2024 · 1 comment

Comments

@PiotrJustyna
Copy link

Hello and first of all great work on the project 👏 👏 👏

I've been using something like this, just very slimmed down and without stack myself for a while and thought I would leave it here in case people are interested. Works great for my purposes and could be a great starting place for Haskell/GHC/Cabal newbies.

FROM alpine:3.20.2

WORKDIR "/root/code/drakon-renderer"

RUN \
  apk update \
  && \
  apk add \
    zsh \
    git \
    openssh \
    curl \
    zlib-dev \
    g++ \
    ghc \
    cabal \
    ncurses-dev \
  && \
  git config --global --add safe.directory "/root/code/drakon-renderer" \
  && \
  cabal update \
  && \
  cabal install hlint hindent \
  && \
  echo "PROMPT='%F{cyan}%n%f %F{magenta}%~%f $ '" >> ~/.zshrc

# 2024-12-02 PJ:
# --------------
# this is where executables
# installed with cabal install are located
ENV PATH="${PATH}:/root/.local/bin"

CMD [ "/bin/zsh" ]
#!/bin/sh

# 2024-12-04 PJ:
# --------------
# At the time of writing this, these directories are covered here:
# https://cabal.readthedocs.io/en/latest/config.html#directories
# Mounting them as volumes allows us to reuse cabal files
# between containers saving a significant amount of build time.
docker volume create cabal-config
docker volume create cabal-cache
docker volume create cabal-state

docker buildx build \
  -t "drakon-renderer:latest" \
  -f "dockerfile" \
  . \
&& \
docker run \
  -it \
  -v "$HOME/.ssh/:/root/.ssh:ro" \
  -v "$(pwd):/root/code/drakon-renderer" \
  -v cabal-config:/root/.config/cabal \
  -v cabal-cache:/root/.cache/cabal \
  -v cabal-state:/root/.local/state/cabal \
  --rm "drakon-renderer:latest"

My local development setup is pretty simple:

  • vs code
  • shell

Here is a sample project I use it with: https://github.com/PiotrJustyna/drakon-renderer

@benz0li
Copy link

benz0li commented Dec 7, 2024

There is also GHC musl – Unofficial binary distributions of GHC on Alpine Linux:

  1. Multi‑arch: linux/amd64, linux/arm64/v8
  2. Built using Hadrian1, from source, without docs
  3. Built using the LLVM backend
    • flavour: perf+llvm+split_sections

Including Dev Containers providing the following tools:

Footnotes

  1. GHC versions ≥ 9.2.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants