Skip to content

Commit 16d2551

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 16d2551

File tree

4 files changed

+222
-138
lines changed

4 files changed

+222
-138
lines changed

8.10/buster/Dockerfile

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,75 @@
1+
FROM debian:buster AS builder
2+
3+
ENV LANG C.UTF-8
4+
5+
# to install ghcup + ghc, cabal and stack
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
ca-certificates \
9+
build-essential \
10+
libffi-dev \
11+
libffi6 \
12+
libgmp-dev \
13+
libgmp10 \
14+
libncurses-dev \
15+
libncurses5 \
16+
libtinfo5 \
17+
curl && \
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+
139
FROM debian:buster
240

341
ENV LANG C.UTF-8
442

43+
# common haskell + stack dependencies
544
RUN apt-get update && \
645
apt-get install -y --no-install-recommends \
746
ca-certificates \
8-
curl \
9-
dirmngr \
1047
g++ \
48+
gcc \
1149
git \
1250
gnupg \
13-
libsqlite3-dev \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1454
libtinfo-dev \
1555
make \
1656
netbase \
17-
openssh-client \
1857
xz-utils \
1958
zlib1g-dev && \
2059
rm -rf /var/lib/apt/lists/*
2160

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

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
65+
# stack should use global ghc
66+
RUN /usr/local/bin/stack config set system-ghc --global true && \
67+
/usr/local/bin/stack config set install-ghc --global false
68+
69+
# ensure any user gets GHC on the path
70+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
71+
chmod +x /etc/profile.d/ghc_path.sh
72+
73+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5374

5475
CMD ["ghci"]

8.10/stretch/Dockerfile

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,75 @@
1+
FROM debian:stretch AS builder
2+
3+
ENV LANG C.UTF-8
4+
5+
# to install ghcup + ghc, cabal and stack
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
ca-certificates \
9+
build-essential \
10+
libffi-dev \
11+
libffi6 \
12+
libgmp-dev \
13+
libgmp10 \
14+
libncurses-dev \
15+
libncurses5 \
16+
libtinfo5 \
17+
curl && \
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+
139
FROM debian:stretch
240

341
ENV LANG C.UTF-8
442

43+
# common haskell + stack dependencies
544
RUN apt-get update && \
645
apt-get install -y --no-install-recommends \
746
ca-certificates \
8-
curl \
9-
dirmngr \
1047
g++ \
48+
gcc \
1149
git \
1250
gnupg \
13-
libsqlite3-dev \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1454
libtinfo-dev \
1555
make \
1656
netbase \
17-
openssh-client \
1857
xz-utils \
1958
zlib1g-dev && \
2059
rm -rf /var/lib/apt/lists/*
2160

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

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
65+
# stack should use global ghc
66+
RUN /usr/local/bin/stack config set system-ghc --global true && \
67+
/usr/local/bin/stack config set install-ghc --global false
68+
69+
# ensure any user gets GHC on the path
70+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
71+
chmod +x /etc/profile.d/ghc_path.sh
72+
73+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5374

5475
CMD ["ghci"]

9.0/buster/Dockerfile

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,75 @@
1+
FROM debian:buster AS builder
2+
3+
ENV LANG C.UTF-8
4+
5+
# to install ghcup + ghc, cabal and stack
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
ca-certificates \
9+
build-essential \
10+
libffi-dev \
11+
libffi6 \
12+
libgmp-dev \
13+
libgmp10 \
14+
libncurses-dev \
15+
libncurses5 \
16+
libtinfo5 \
17+
curl && \
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+
139
FROM debian:buster
240

341
ENV LANG C.UTF-8
442

43+
# common haskell + stack dependencies
544
RUN apt-get update && \
645
apt-get install -y --no-install-recommends \
746
ca-certificates \
8-
curl \
9-
dirmngr \
1047
g++ \
48+
gcc \
1149
git \
1250
gnupg \
13-
libsqlite3-dev \
51+
libc6-dev \
52+
libffi-dev \
53+
libgmp-dev \
1454
libtinfo-dev \
1555
make \
1656
netbase \
17-
openssh-client \
1857
xz-utils \
1958
zlib1g-dev && \
2059
rm -rf /var/lib/apt/lists/*
2160

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

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
65+
# stack should use global ghc
66+
RUN /usr/local/bin/stack config set system-ghc --global true && \
67+
/usr/local/bin/stack config set install-ghc --global false
68+
69+
# ensure any user gets GHC on the path
70+
RUN echo 'export PATH="/opt/ghc/bin:$PATH"' >> /etc/profile.d/ghc_path.sh && \
71+
chmod +x /etc/profile.d/ghc_path.sh
72+
73+
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/bin:$PATH
5374

5475
CMD ["ghci"]

0 commit comments

Comments
 (0)