Skip to content

Commit 04b88e0

Browse files
committed
Switch to ghcup for installation method
The current installation method is dependent on debian ghc and cabal packaging, which often is slow to be updated. Additionally, ghcup is becoming a standard installation technique so we probably don't want to reinvent the wheel here. It also provides an easier path to support windows and arm based images.
1 parent d9bf04e commit 04b88e0

File tree

4 files changed

+227
-132
lines changed

4 files changed

+227
-132
lines changed

8.10/buster/Dockerfile

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
1-
FROM debian:buster
1+
FROM debian:buster AS builder
22

33
ENV LANG C.UTF-8
44

5+
# to install ghcup + ghc, cabal and stack
56
RUN apt-get update && \
67
apt-get install -y --no-install-recommends \
8+
build-essential \
79
ca-certificates \
810
curl \
9-
dirmngr \
10-
g++ \
11+
libffi-dev \
12+
libffi6 \
13+
libgmp-dev \
14+
libgmp10 \
15+
libncurses-dev \
16+
libncurses5 \
17+
libtinfo5 && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# install ghcup
21+
ARG GHCUP_VERSION=0.1.16.2
22+
RUN curl --proto '=https' --tlsv1.2 -sSf https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION > /usr/bin/ghcup && \
23+
chmod +x /usr/bin/ghcup
24+
25+
# install cabal
26+
ARG CABAL_VERSION=3.4.0.0
27+
RUN ghcup install cabal -i /usr/local/bin $CABAL_VERSION
28+
29+
# install stack
30+
ARG STACK_VERSION=2.7.3
31+
RUN ghcup install stack -i /usr/local/bin $STACK_VERSION
32+
33+
# install GHC into /opt/ghc + remove profiling support
34+
ARG GHC_VERSION=8.10.4
35+
RUN ghcup install ghc -i /opt/ghc $GHC_VERSION && \
36+
find /opt/ghc/lib -name "*.p_hi" -type f -delete && \
37+
find /opt/ghc/lib -name "*_p.a" -type f -delete
38+
39+
FROM debian:buster
40+
41+
ENV LANG C.UTF-8
42+
43+
# common haskell + stack dependencies
44+
RUN apt-get update && \
45+
apt-get install -y --no-install-recommends \
46+
ca-certificates \
1147
git \
48+
gcc \
1249
gnupg \
50+
g++ \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1354
libsqlite3-dev \
1455
libtinfo-dev \
1556
make \
@@ -19,36 +60,18 @@ RUN apt-get update && \
1960
zlib1g-dev && \
2061
rm -rf /var/lib/apt/lists/*
2162

22-
ARG GHC=8.10.4
23-
ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574
24-
ARG CABAL_INSTALL=3.4
63+
COPY --from=builder /usr/local/bin /usr/local/bin
64+
COPY --from=builder /opt/ghc/bin /opt/ghc/bin
65+
COPY --from=builder /opt/ghc/lib /opt/ghc/lib
2566

26-
RUN export GNUPGHOME="$(mktemp -d)" && \
27-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \
28-
gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \
29-
gpgconf --kill all && \
30-
echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list && \
31-
apt-get update && \
32-
apt-get install -y --no-install-recommends \
33-
cabal-install-${CABAL_INSTALL} \
34-
ghc-${GHC} && \
35-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/*
36-
37-
ARG STACK=2.7.3
38-
ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442
39-
ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D
40-
41-
RUN export GNUPGHOME="$(mktemp -d)" && \
42-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_KEY} && \
43-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_RELEASE_KEY} && \
44-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \
45-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \
46-
gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \
47-
tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \
48-
/usr/local/bin/stack config set system-ghc --global true && \
49-
/usr/local/bin/stack config set install-ghc --global false && \
50-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz
51-
52-
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH
67+
# stack should use global ghc
68+
RUN /usr/local/bin/stack config set system-ghc --global true && \
69+
/usr/local/bin/stack config set install-ghc --global false
70+
71+
# ensure any user gets GHC on the path
72+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
73+
chmod +x /etc/profile.d/ghc_path.sh
74+
75+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5376

5477
CMD ["ghci"]

8.10/stretch/Dockerfile

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
1-
FROM debian:stretch
1+
FROM debian:stretch AS builder
22

33
ENV LANG C.UTF-8
44

5+
# to install ghcup + ghc, cabal and stack
56
RUN apt-get update && \
67
apt-get install -y --no-install-recommends \
8+
build-essential \
79
ca-certificates \
810
curl \
9-
dirmngr \
10-
g++ \
11+
libffi-dev \
12+
libffi6 \
13+
libgmp-dev \
14+
libgmp10 \
15+
libncurses-dev \
16+
libncurses5 \
17+
libtinfo5 && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# install ghcup
21+
ARG GHCUP_VERSION=0.1.16.2
22+
RUN curl --proto '=https' --tlsv1.2 -sSf https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION > /usr/bin/ghcup && \
23+
chmod +x /usr/bin/ghcup
24+
25+
# install cabal
26+
ARG CABAL_VERSION=3.4.0.0
27+
RUN ghcup install cabal -i /usr/local/bin $CABAL_VERSION
28+
29+
# install stack
30+
ARG STACK_VERSION=2.7.3
31+
RUN ghcup install stack -i /usr/local/bin $STACK_VERSION
32+
33+
# install GHC into /opt/ghc + remove profiling support
34+
ARG GHC_VERSION=8.10.4
35+
RUN ghcup install ghc -i /opt/ghc $GHC_VERSION && \
36+
find /opt/ghc/lib -name "*.p_hi" -type f -delete && \
37+
find /opt/ghc/lib -name "*_p.a" -type f -delete
38+
39+
FROM debian:stretch
40+
41+
ENV LANG C.UTF-8
42+
43+
# common haskell + stack dependencies
44+
RUN apt-get update && \
45+
apt-get install -y --no-install-recommends \
46+
ca-certificates \
1147
git \
48+
gcc \
1249
gnupg \
50+
g++ \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1354
libsqlite3-dev \
1455
libtinfo-dev \
1556
make \
@@ -19,36 +60,18 @@ RUN apt-get update && \
1960
zlib1g-dev && \
2061
rm -rf /var/lib/apt/lists/*
2162

22-
ARG GHC=8.10.4
23-
ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574
24-
ARG CABAL_INSTALL=3.4
63+
COPY --from=builder /usr/local/bin /usr/local/bin
64+
COPY --from=builder /opt/ghc/bin /opt/ghc/bin
65+
COPY --from=builder /opt/ghc/lib /opt/ghc/lib
2566

26-
RUN export GNUPGHOME="$(mktemp -d)" && \
27-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \
28-
gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \
29-
gpgconf --kill all && \
30-
echo 'deb http://downloads.haskell.org/debian stretch main' > /etc/apt/sources.list.d/ghc.list && \
31-
apt-get update && \
32-
apt-get install -y --no-install-recommends \
33-
cabal-install-${CABAL_INSTALL} \
34-
ghc-${GHC} && \
35-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/*
36-
37-
ARG STACK=2.7.3
38-
ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442
39-
ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D
40-
41-
RUN export GNUPGHOME="$(mktemp -d)" && \
42-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_KEY} && \
43-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_RELEASE_KEY} && \
44-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \
45-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \
46-
gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \
47-
tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \
48-
/usr/local/bin/stack config set system-ghc --global true && \
49-
/usr/local/bin/stack config set install-ghc --global false && \
50-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz
51-
52-
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH
67+
# stack should use global ghc
68+
RUN /usr/local/bin/stack config set system-ghc --global true && \
69+
/usr/local/bin/stack config set install-ghc --global false
70+
71+
# ensure any user gets GHC on the path
72+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
73+
chmod +x /etc/profile.d/ghc_path.sh
74+
75+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5376

5477
CMD ["ghci"]

9.0/buster/Dockerfile

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
1-
FROM debian:buster
1+
FROM debian:buster AS builder
22

33
ENV LANG C.UTF-8
44

5+
# to install ghcup + ghc, cabal and stack
56
RUN apt-get update && \
67
apt-get install -y --no-install-recommends \
8+
build-essential \
79
ca-certificates \
810
curl \
9-
dirmngr \
10-
g++ \
11+
libffi-dev \
12+
libffi6 \
13+
libgmp-dev \
14+
libgmp10 \
15+
libncurses-dev \
16+
libncurses5 \
17+
libtinfo5 && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# install ghcup
21+
ARG GHCUP_VERSION=0.1.16.2
22+
RUN curl --proto '=https' --tlsv1.2 -sSf https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION > /usr/bin/ghcup && \
23+
chmod +x /usr/bin/ghcup
24+
25+
# install cabal
26+
ARG CABAL_VERSION=3.4.0.0
27+
RUN ghcup install cabal -i /usr/local/bin $CABAL_VERSION
28+
29+
# install stack
30+
ARG STACK_VERSION=2.7.3
31+
RUN ghcup install stack -i /usr/local/bin $STACK_VERSION
32+
33+
# install GHC into /opt/ghc + remove profiling support
34+
ARG GHC_VERSION=9.0.1
35+
RUN ghcup install ghc -i /opt/ghc $GHC_VERSION && \
36+
find /opt/ghc/lib -name "*.p_hi" -type f -delete && \
37+
find /opt/ghc/lib -name "*_p.a" -type f -delete
38+
39+
FROM debian:buster
40+
41+
ENV LANG C.UTF-8
42+
43+
# common haskell + stack dependencies
44+
RUN apt-get update && \
45+
apt-get install -y --no-install-recommends \
46+
ca-certificates \
1147
git \
48+
gcc \
1249
gnupg \
50+
g++ \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1354
libsqlite3-dev \
1455
libtinfo-dev \
1556
make \
@@ -19,36 +60,18 @@ RUN apt-get update && \
1960
zlib1g-dev && \
2061
rm -rf /var/lib/apt/lists/*
2162

22-
ARG GHC=9.0.1
23-
ARG DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574
24-
ARG CABAL_INSTALL=3.4
63+
COPY --from=builder /usr/local/bin /usr/local/bin
64+
COPY --from=builder /opt/ghc/bin /opt/ghc/bin
65+
COPY --from=builder /opt/ghc/lib /opt/ghc/lib
2566

26-
RUN export GNUPGHOME="$(mktemp -d)" && \
27-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY} && \
28-
gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc && \
29-
gpgconf --kill all && \
30-
echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list && \
31-
apt-get update && \
32-
apt-get install -y --no-install-recommends \
33-
cabal-install-${CABAL_INSTALL} \
34-
ghc-${GHC} && \
35-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/*
36-
37-
ARG STACK=2.7.3
38-
ARG STACK_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442
39-
ARG STACK_RELEASE_KEY=2C6A674E85EE3FB896AFC9B965101FF31C5C154D
40-
41-
RUN export GNUPGHOME="$(mktemp -d)" && \
42-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_KEY} && \
43-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_RELEASE_KEY} && \
44-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \
45-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \
46-
gpg --batch --trusted-key 0x575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \
47-
tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 && \
48-
/usr/local/bin/stack config set system-ghc --global true && \
49-
/usr/local/bin/stack config set install-ghc --global false && \
50-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz
51-
52-
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH
67+
# stack should use global ghc
68+
RUN /usr/local/bin/stack config set system-ghc --global true && \
69+
/usr/local/bin/stack config set install-ghc --global false
70+
71+
# ensure any user gets GHC on the path
72+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
73+
chmod +x /etc/profile.d/ghc_path.sh
74+
75+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5376

5477
CMD ["ghci"]

0 commit comments

Comments
 (0)