Skip to content

Instantly share code, notes, and snippets.

@dustin
Created November 1, 2017 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustin/ea787ad087ca31817fd592e001dbd5b2 to your computer and use it in GitHub Desktop.
Save dustin/ea787ad087ca31817fd592e001dbd5b2 to your computer and use it in GitHub Desktop.
Dockerfile for arm linux haskell build environment.
# FROM arm32v7/debian:stretch
FROM resin/rpi-raspbian:stretch
ENV QEMU_SET_ENV=QEMU_CPU=cortex-a9
RUN apt-get update
RUN apt-get install -y netbase curl llvm-3.7 # haskell-stack
RUN curl -sSL https://get.haskellstack.org/ | sh
COPY stack-entry /bin/stack-entry
VOLUME /root
ENTRYPOINT /bin/stack-entry
# ENTRYPOINT stack setup
#!/bin/sh -e
if [ ! -d /root/.stack ]
then
stack setup
fi
exec /bin/bash
@dustin
Copy link
Author

dustin commented Nov 8, 2017

This is how I build my docker environment for haskell code. (can be found at dustin/armstack which is how I'll refer to it below)

Setup

You'll need to specify a persistent mount point for /root to use this. The first time it runs, it sets up a build environment, which can take several minutes. After that, /usr/local/bin/stack is available and ready to run builds.

Failure

However, /usr/local/bin/stack doesn't seem to work as an entry point. e.g.:

docker run -ti --rm -v $YOURROOT:/root --entrypoint "" dustin/armstack /usr/local/bin/stack

fails immediately with qemu: uncaught target signal 4 (Illegal instruction) - core dumped

Workaround

However, the following is fine:

docker run -ti --rm -v $YOURROOT:/root --entrypoint "" dustin/armstack /usr/bin/env /usr/local/bin/stack

Test Environments

Mac

Client:
 Version:      17.11.0-ce-rc2
 API version:  1.34
 Go version:   go1.8.4
 Git commit:   d7062e5
 Built:        Wed Nov  1 22:08:25 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.11.0-ce-rc2
 API version:  1.34 (minimum version 1.12)
 Go version:   go1.8.5
 Git commit:   d7062e5
 Built:        Wed Nov  1 22:14:52 2017
 OS/Arch:      linux/amd64
 Experimental: true

Linux

Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:42:09 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:48 2017
 OS/Arch:      linux/amd64
 Experimental: false

@seanjhulse
Copy link

Hey, so, I would use a few things differently and maybe leverage docker-compose:

  1. docker-compose.yml
version: '3.1'

services:
  haskell:
    build: .
    volumes:
      - "/:/root"
    stdin_open: true
    tty: true
  1. Dockerfile
# FROM arm32v7/debian:stretch
FROM resin/rpi-raspbian:stretch

ENV QEMU_SET_ENV=QEMU_CPU=cortex-a9

RUN apt-get update
RUN apt-get install -y netbase curl llvm-3.7 # haskell-stack
RUN curl -sSL https://get.haskellstack.org/ | sh
RUN /usr/local/bin/stack setup
ENTRYPOINT [ "/bin/bash" ]
# ENTRYPOINT stack setup
  1. Command to run:

docker-compose up --build

That's all I needed to get the container up and running. I have the same Mac OSx as you but I have the newest stable version of docker. Make sure your docker-compose file is version '3.1' and not version '3' because I was having issues with mounting wth version '3'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment