Skip to content

docker-haskell micro? #142

Closed
Closed
@PiotrJustyna

Description

@PiotrJustyna

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions