-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfileHaskell
115 lines (96 loc) · 4.8 KB
/
DockerfileHaskell
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
# Use the latest official Ubuntu image as a base
FROM ubuntu:22.04
# large chunks of this file "inspired by" aka. plagerised from https://github.com/vzarytovskii/haskell-dev-env/blob/master/.devcontainer/Dockerfile
# use
# docker build -t "haskell" -f DockerfileHaskell .
# docker tag haskell theghostjw/haskell:latest
# docker push theghostjw/haskell:latest
# Set environment variables to avoid interactive prompts during package installation
ARG GHC_VERSION=9.8.2
ARG CABAL_VERSION=3.12.1.0
ARG HLS_VERSION=2.9.0.1
# for some reason hls trys to download stack if it is not there
ARG STACK_VERSION=2.15.7
ENV USERNAME=vscode \
# modified from https://github.com/vzarytovskii/haskell-dev-env/blob/master/.devcontainer/Dockerfile
# this 1000 is aready taken by ubuntu
USER_UID=1001 \
USER_GID=1001 \
DEBIAN_FRONTEND=noninteractive \
GHC_VERSION=${GHC_VERSION} \
CABAL_VERSION=${CABAL_VERSION}
# Update the package list and install some basic utilities
RUN apt-get update && \
apt-get install -y \
wget \
git \
sudo \
# GHCUp Requirements https://www.haskell.org/ghcup/install/#version-23
build-essential \
curl \
bash \
build-essential \
libffi-dev \
libffi8ubuntu1 \
libgmp-dev \
libgmp10 \
libncurses-dev \
pkg-config \
# used by zlib used by
zlib1g-dev \
&& apt-get clean
# Explicitly export PATH changes
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}
# Download ghciwatch binary as root
RUN curl -L -o /usr/local/bin/ghciwatch https://github.com/MercuryTechnologies/ghciwatch/releases/download/v1.0.1/ghciwatch-x86_64-linux && \
chmod +x /usr/local/bin/ghciwatch
# Ensure the vscode user has ownership of the ghciwatch binary
RUN chown ${USER_UID}:${USER_GID} /usr/local/bin/ghciwatch
# Set working directory and path for vscode user
USER ${USER_UID}:${USER_GID}
WORKDIR /home/${USERNAME}
ENV PATH="/home/${USERNAME}/.local/bin:/home/${USERNAME}/.cabal/bin:/home/${USERNAME}/.ghcup/bin:$PATH"
# Set path to user
RUN echo "export PATH=${PATH}" >> /home/${USERNAME}/.profile
# Ensure the vscode user has ownership of its home directory
RUN chown -R ${USER_UID}:${USER_GID} /home/${USERNAME}
# get ghcup install script
# Main settings:
# * BOOTSTRAP_HASKELL_NONINTERACTIVE - any nonzero value for noninteractive installation
# * BOOTSTRAP_HASKELL_NO_UPGRADE - any nonzero value to not trigger the upgrade
# * BOOTSTRAP_HASKELL_MINIMAL - any nonzero value to only install ghcup
# * GHCUP_USE_XDG_DIRS - any nonzero value to respect The XDG Base Directory Specification
# * BOOTSTRAP_HASKELL_VERBOSE - any nonzero value for more verbose installation
# * BOOTSTRAP_HASKELL_GHC_VERSION - the ghc version to install
# * BOOTSTRAP_HASKELL_CABAL_VERSION - the cabal version to install
# * BOOTSTRAP_HASKELL_CABAL_XDG - don't disable the XDG logic (this doesn't force XDG though, because cabal is confusing)
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK - disable installation of stack
# * BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK - disable installation stack ghcup hook
# * BOOTSTRAP_HASKELL_INSTALL_HLS - whether to install latest hls
# * BOOTSTRAP_HASKELL_ADJUST_BASHRC - whether to adjust PATH in bashrc (prepend)
# * BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG - whether to adjust mingw paths in cabal.config on windows
# * BOOTSTRAP_HASKELL_DOWNLOADER - which downloader to use (default: curl)
# * GHCUP_BASE_URL - the base url for ghcup binary download (use this to overwrite https://downloads.haskell.org/~ghcup with a mirror)
# * GHCUP_MSYS2_ENV - the msys2 environment to use on windows, see https://www.msys2.org/docs/environments/ (defauts to MINGW64, MINGW32 or CLANGARM64, depending on the architecture)
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=${GHC_VERSION} \
BOOTSTRAP_HASKELL_CABAL_VERSION=${CABAL_VERSION} \
sh
# RUN ghcup --url-source=https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.8.yaml install hls 2.9.0.1
RUN ghcup install hls ${HLS_VERSION} \
ghcup set hls ${HLS_VERSION}
# for some reason hls trys to download stack if it is not there
RUN ghcup install stack ${STACK_VERSION} \
ghcup set stack ${STACK_VERSION}
# install other tools
RUN cabal update
RUN cabal install hpack
# Copy any local files to the container (if needed)
# COPY . /home/dockeruser/
# Expose a port if the application needs it
# EXPOSE 8080
# Specify the default command to run when the container starts
CMD ["bash"]