Skip to content

Commit

Permalink
Fix building container + set default resolver to nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
vzarytovskii committed Dec 27, 2023
1 parent fe56df7 commit 408177e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
41 changes: 23 additions & 18 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM debian:bullseye-slim as base
FROM debian:bookworm-slim as base

ENV LANG C.UTF-8

ARG GHC_VERSION=9.4.4
ARG GHC_VERSION=9.6.3
ARG STACK_VERSION=recommended
ARG STACK_RESOLVER=default
ARG STACK_RESOLVER=nightly
ARG CABAL_VERSION=recommended
ARG HLS_VERSION=recommended
ARG LLVM_VERSION=14
ARG LLVM_VERSION=17

ENV USERNAME=vscode \
USER_UID=1000 \
Expand All @@ -22,10 +22,16 @@ ENV USERNAME=vscode \

RUN ulimit -n 8192

RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils bash build-essential ca-certificates curl gcc git gnupg libffi-dev libffi7 libgmp-dev libgmp-dev libgmp10 libicu-dev libncurses-dev libncurses5 libnuma1 libnuma-dev libtinfo5 lsb-release make procps software-properties-common sudo wget xz-utils z3 zlib1g-dev

RUN wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && /tmp/llvm.sh ${LLVM_VERSION} && rm /tmp/llvm.sh
RUN VERSION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2) && \
apt-get update && \
apt-get install -y --no-install-recommends software-properties-common wget && \
# I don't know why, nor do I have any mental capacity to figure it out,
# but we need to add the repository twice, otherwise it doesn't work (repo isn't being added)
add-apt-repository -y -s -n "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${LLVM_VERSION} main" && \
add-apt-repository -y -s -n "deb http://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${LLVM_VERSION} main" && \
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
apt-get update && \
apt-get install -y --no-install-recommends apt-utils bash build-essential ca-certificates curl gcc git gnupg libffi-dev libffi8 libgmp-dev libgmp-dev libgmp10 libicu-dev libncurses-dev libncurses5 libnuma1 libnuma-dev libtinfo5 lsb-release make procps sudo xz-utils z3 zlib1g-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION

RUN groupadd --gid ${USER_GID} ${USERNAME} && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} && \
Expand Down Expand Up @@ -66,7 +72,6 @@ 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 && \
test "${STACK_RESOLVER}" = 'default' && export STACK_RESOLVER=$(stack ls snapshots remote | grep -B1 "\(ghc-${GHC_VERSION}\)" | head -2 | sed -n -e 's/^Resolver name: \(\S\+\)$/\1/p'); \
stack config --system-ghc set resolver ${STACK_RESOLVER}

# Set global custom defaults for stack.
Expand All @@ -79,21 +84,21 @@ FROM tooling as packages

# Install global packages.
# Versions are pinned, since we don't want to accidentally break anything (by always installing latest).
RUN cabal install --haddock-hoogle \
# fsnotify-0.3.0.1 \
RUN cabal install --haddock-hoogle --minimize-conflict-set \
fsnotify-0.4.1.0 \
haskell-dap-0.0.16.0 \
ghci-dap-0.0.20.0 \
ghci-dap-0.0.22.0 \
haskell-debug-adapter-0.0.39.0 \
hlint-3.5 \
apply-refact-0.11.0.0 \
retrie-1.2.1.1 \
hlint-3.6.1 \
apply-refact-0.14.0.0 \
retrie-1.2.2 \
hoogle-5.0.18.3 \
ormolu-0.5.2.0
ormolu-0.7.2.0

#FROM packages as hoogle
FROM packages as hoogle

# Generate hoogle db
#RUN hoogle generate && stack hoogle
RUN hoogle generate --download --haskell

ENV DEBIAN_FRONTEND=dialog

Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"build": {
"args": {
"USERNAME": "vscode",
"GHC_VERSION": "9.4.4",
"GHC_VERSION": "9.6.3",
"STACK_VERSION": "recommended",
"STACK_RESOLVER": "default",
"STACK_RESOLVER": "nightly",
"CABAL_VERSION": "recommended",
"HLS_VERSION": "recommended",
"LLVM_VERSION": "14"
"LLVM_VERSION": "17"
},
"context": "..",
"dockerfile": "Dockerfile"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# (A highly opinionated) Docker image for Haskell development
# A (highly opinionated) Docker image for Haskell development

**Note**: The way this container setup is very opinionaed, you may want to check out [an official dev containter for Haskell](https://github.com/microsoft/vscode-dev-containers/tree/main/containers/haskell).

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents**

- [(A highly opinionated) Docker image for Haskell development](#a-highly-opinionated-docker-image-for-haskell-development)
- [A (highly opinionated) Docker image for Haskell development](#a-highly-opinionated-docker-image-for-haskell-development)
- [Visual Studio Code: DevContainer for Haskell](#visual-studio-code-devcontainer-for-haskell)
- [What is this](#what-is-this)
- [How to use this](#how-to-use-this)
Expand Down

0 comments on commit 408177e

Please sign in to comment.