forked from vzarytovskii/haskell-dev-env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
131 lines (108 loc) · 3.5 KB
/
Dockerfile
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
FROM debian:bullseye AS base
ARG GHC_VERSION=8.10.7
ARG STACK_RESOLVER=lts-18.19
ARG STACK_VERSION=2.7.5
ARG CABAL_VERSION=3.6.2.0
ARG HLS_VERSION=1.6.1.0
ENV USERNAME=haskeller \
USER_UID=2001 \
USER_GID=2001 \
DEBIAN_FRONTEND=noninteractive \
GHC_VERSION=${GHC_VERSION} \
STACK_RESOLVER=${STACK_RESOLVER} \
STACK_VERSION=${STACK_VERSION} \
CABAL_VERSION=${CABAL_VERSION} \
HLS_VERSION=${HLS_VERSION}
RUN apt-get update
RUN apt-get install -y \
apt-utils \
bash \
build-essential \
ca-certificates \
curl \
dpkg-dev \
gcc \
g++ \
git \
gnupg \
libc6-dev \
libffi-dev \
libffi7 \
libgmp-dev \
libgmp10 \
libicu-dev \
libncurses-dev \
libncurses5 \
libnuma-dev \
libsqlite3-dev \
libtinfo-dev \
libtinfo5 \
lsb-release \
make \
netbase \
openssh-client \
procps \
software-properties-common \
sudo \
wget \
xz-utils \
z3 \
zlib1g-dev
# New build stage
# https://docs.docker.com/develop/develop-images/multistage-build/
FROM base as tools
# Install LLVM
RUN wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && /tmp/llvm.sh 12 && rm /tmp/llvm.sh
RUN groupadd --gid $USER_GID $USERNAME && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid $USER_UID --gid $USER_GID -m $USERNAME && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
USER ${USER_UID}:${USER_GID}
WORKDIR /home/${USERNAME}
ENV PATH="/home/${USERNAME}/.local/bin:/home/${USERNAME}/.cabal/bin:/home/${USERNAME}/.ghcup/bin:$PATH"
RUN echo "export PATH=$PATH" >> /home/$USERNAME/.profile
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=yes \
BOOTSTRAP_HASKELL_NO_UPGRADE=yes
# Install ghcup
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
# Set the GHC version.
RUN ghcup install ghc ${GHC_VERSION} && ghcup set ghc ${GHC_VERSION}
# Install stack
RUN ghcup install stack ${STACK_VERSION} && ghcup set stack ${STACK_VERSION}
# Set system-ghc, install-ghc and resolver for stack.
RUN ((stack ghc -- --version 2>/dev/null) || true) && \
# Set global defaults for stack.
stack config --system-ghc set system-ghc true --global && \
stack config --system-ghc set install-ghc false --global && \
stack config --system-ghc set resolver $STACK_RESOLVER
# Set global custom defaults for stack.
RUN printf "ghc-options:\n \"\$everything\": -haddock\n" >> /home/${USERNAME}/.stack/config.yaml
# Install hls
RUN ghcup install hls ${HLS_VERSION} && ghcup set hls ${HLS_VERSION}
# New build stage
FROM tools as cabal
# Install cabal and cabal-install
RUN ghcup install cabal ${CABAL_VERSION} && ghcup set cabal ${CABAL_VERSION}
RUN cabal update && cabal new-install -j1 cabal-install
# Configure cabal
RUN cabal user-config update -f && \
sed -i 's/-- ghc-options:/ghc-options: -haddock/g' /home/${USERNAME}/.cabal/config
# New build stage
FROM cabal as cabal1
# Install global packages.
# Versions are pinned, since we don't want to accidentally break anything (by always installing latest).
RUN cabal install -j1 --haddock-hoogle -v \
haskell-dap-0.0.15.0 \
ghci-dap-0.0.17.0 \
haskell-debug-adapter-0.0.35.0 \
hlint-3.2.7 \
apply-refact-0.9.3.0 \
retrie-1.1.0.0 \
stylish-haskell-0.13.0.0 \
hoogle-5.0.18.3 \
ormolu-0.1.3.1 \
liquidhaskell-0.8.10.2
# Generate hoogle db
RUN stack exec hoogle generate && stack hoogle
ENV DEBIAN_FRONTEND=dialog
ENTRYPOINT ["/bin/bash"]