File: Dockerfile.ghc843

package info (click to toggle)
ghc 9.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 177,780 kB
  • sloc: haskell: 494,441; ansic: 70,262; javascript: 9,423; sh: 8,537; python: 2,646; asm: 1,725; makefile: 1,333; xml: 196; cpp: 167; perl: 143; ruby: 84; lisp: 7
file content (95 lines) | stat: -rw-r--r-- 3,326 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Dockerfile to load a haskell environment for running binary's test suite.
#
# Building the Dockerfile creates an image which has the haskell environment
# with ghc and cabal setup and ready to use.
#
# Use a docker volume to cache built dependencies. It will greatly speed up
# running the tests repeatedly.
#
# Create a volume:
#
#   docker volume create cabal-store-cache
#
# How to build:
#
#   docker build -f docker/Dockerfile.ghc843 -t haskell/binary .
#
# How to run (caching the cabal store directory), default is 'cabal new-test':
#
#   docker run -it haskell/binary -v cabal-store-cache:/root/.cabal/store
#
# Run 'cabal new-bench' or any other command (bash, to get into the machine):
#
#   docker run -it haskell/binary -v cabal-store-cache:/root/.cabal/store \
#     cabal new-bench
#
# Hacks to build binary:
#
#   1) Copy all files from the host machine.
#
#   2) Rename binary to binary-next. This is an unfortunate consequence of
#      binary being used by its test and benchmark dependencies.
#      Not renaming binary will make cabal confused and it'll fail to build.
#
#      Cabal can be made to build properly by carefully installing the test
#      and benchmark dependencies manually, like it's done in .travis.yml.
#      Unfortunately that setup is very fragile since changing the
#      dependencies in binary.cabal also requires updating .travis.yml.
#      Thus .travis.yml gets out of sync when we forget.
#      This method also doesn't work with the nix-style commands which
#      themselves take care of installing dependencies.
#      The simples workaround I've found, and the only thing that works
#      with nix-style commands, is to simply rename the package
#
#   3) Do 'cabal sdist' to get only the files for source distribution.
#
#   4) Unpack the .tar.gz file from (3) and copy generics-bench.cache.gz
#      to the same dir.
#
#   5) The setup is complete. You may run cabal new-test,
#      or any other command.
#

FROM debian:stable

# setup locale.
# not setting a locale will make some apps fail when outputting utf8.
RUN apt-get update && \
    apt-get install -y locales && \
    locale-gen C.UTF-8 && \
    /usr/sbin/update-locale LANG=C.UTF-8 && \
    apt-get remove -y locales

ENV LANG C.UTF-8

# key used by haskell repo
RUN apt-get update && apt-get install -y gnupg dirmngr
RUN apt-key adv --keyserver keyserver.ubuntu.com  --recv-keys BA3CBA3FFE22B574

# add haskell repo for debian
RUN echo "deb http://downloads.haskell.org/debian stretch main" > /etc/apt/sources.list.d/haskell.list

RUN apt update && apt install -y cabal-install-2.2
RUN apt update && apt install -y ghc-8.4.3
RUN apt update && apt-get install -y zlib1g-dev

ENV PATH=/opt/ghc/bin:$PATH

RUN cabal update

COPY . /workdir/copy

WORKDIR /workdir/copy
RUN sed -i.bak -e 's/name:\s*binary/name: binary-next/' binary.cabal
RUN mv binary.cabal binary-next.cabal
RUN cabal sdist

WORKDIR /workdir/builddir
RUN tar xf /workdir/copy/dist/*.tar.gz -C /workdir/builddir
RUN mv /workdir/builddir/binary-* /workdir/builddir/binary-next
# generics-bench.cache.gz is not part of the binary distribution,
# it's too large. It only lives in the git repo. Copy it manually.
RUN mv /workdir/copy/generics-bench.cache.gz /workdir/builddir/binary-next
WORKDIR /workdir/builddir/binary-next

CMD cabal new-test