Skip to content

Commit

Permalink
Merge pull request #1431 from AmpersandTarski/feature/ampersand-speci…
Browse files Browse the repository at this point in the history
…fic-image

Feature/ampersand specific image
  • Loading branch information
hanjoosten committed Jul 31, 2023
2 parents 82b2799 + 2b68f84 commit 1f24feb
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 70 deletions.
134 changes: 69 additions & 65 deletions .devcontainer/DockerfileUpstream
Original file line number Diff line number Diff line change
@@ -1,104 +1,108 @@
FROM debian:bullseye as base
# This .devcontainer stuff is shamelessly copied from github.com/vzarytovskii/haskell-dev-env
FROM ubuntu:focal as base
## Inspiration from https://stackoverflow.com/questions/67680726/installing-haskells-cabal-or-ghcup-inside-a-dockerfile-wont-work
ENV TZ=Europe/Berlin
ARG USERNAME=vscode
ARG GHC_VERSION=8.10.7
ARG STACK_VERSION=2.11.1
ARG STACK_RESOLVER=lts-18.28
ARG CABAL_VERSION=3.6.2.0
ARG HLS_VERSION=2.0.0.1
ARG LLVM_VERSION=12


ENV USERNAME=${USERNAME} \
USER_UID=1000 \
USER_GID=1000 \
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF8

RUN ulimit -n 8192

RUN export LANG=C.UTF8
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
LANG=C.UTF8 \
WDIR=/home/${USERNAME}


# install dependencies (source: https://www.haskell.org/ghcup/install/ )
RUN \
apt-get update -y && \
apt-get install -y --no-install-recommends \
curl \
libnuma-dev \
zlib1g-dev \
libgmp-dev \
libgmp10 \
git \
wget \
lsb-release \
software-properties-common \
gnupg2 \
apt-transport-https \
gcc \
autoconf \
automake \
build-essential \
&& rm -rf /var/lib/apt/lists/*

RUN groupadd --gid $USER_GID $USERNAME && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid $USER_UID --gid $USER_GID -m $USERNAME && \
mkdir -p /etc/sudoers.d && \
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
RUN ulimit -n 8192

FROM base as tooling

ENV GHC_VERSION=${GHC_VERSION} \
CABAL_VERSION=${CABAL_VERSION} \
STACK_VERSION=${STACK_VERSION} \
STACK_RESOLVER=${STACK_RESOLVER}
# install gpg keys
# ARG GPG_KEY=BA3CBA3FFE22B574
# RUN gpg --batch --keyserver keys.openpgp.org --recv-keys $GPG_KEY
# manual installation: see https://www.haskell.org/ghcup/install/#manual-installation

# install ghcup
# Inspiration: http://haskell.org/ghcup/install
# Install ghcup as the 'vscode' user
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 cabal-iinstall
RUN ghcup install cabal ${CABAL_VERSION} && ghcup set cabal ${CABAL_VERSION}

# Update Cabal.
RUN cabal update && cabal new-install cabal-install

# Configure cabal
RUN cabal user-config update -f && \
sed -i 's/-- ghc-options:/ghc-options: -haddock/g' ~/.cabal/config
# Add ghcup and cabal to the PATH
ENV PATH="${WDIR}/.cabal/bin:${WDIR}/.ghcup/bin:${PATH}:${WDIR}/.local/bin:${PATH}"

# Install stack
RUN ghcup install stack ${STACK_VERSION} && ghcup set stack ${STACK_VERSION}
ARG GHC=8.10.7
ARG CABAL=3.10.1.0
ARG HLS=2.0.0.1
ARG STACK=2.11.1

# 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
# install GHC and cabal

# Temporary required, because http2-4.0.0 is broken, and used to build haddock. See https://github.com/kazu-yamamoto/http2/issues/42
# RUN stack install http2-3.0.3
RUN ghcup install ghc --set ${GHC} && \
ghcup install cabal --set ${CABAL} && \
ghcup install stack --set ${STACK} && \
ghcup install hls --set ${HLS}

# Set global custom defaults for stack.
RUN printf "ghc-options:\n \"\$everything\": -haddock\n" >> ~/.stack/config.yaml

ENV HLS_VERSION=${HLS_VERSION}

# Install hls
RUN ghcup install hls ${HLS_VERSION} && ghcup set hls ${HLS_VERSION}

FROM tooling as packages
FROM base as tools

# Install global packages.
# Versions are pinned, since we don't want to accidentally break anything (by always installing latest).
# RUN cabal install -v haskell-dap-0.0.15.0
RUN cabal install -v haskell-dap-0.0.15.0 && \
cabal install -v stylish-haskell-0.13.0.0 && \
cabal install -v ormolu-0.1.3.1
# RUN cabal install -v ghci-dap-0.0.19.0
# RUN cabal install -v haskell-debug-adapter-0.0.37.0
# RUN cabal install -v hlint-3.2.7
# RUN cabal install -v apply-refact-0.9.3.0
# RUN cabal install -v retrie-1.1.0.0
# RUN cabal install -v stylish-haskell-0.13.0.0
# # RUN cabal install -v hoogle-5.0.18.3
RUN cabal install -v ormolu-0.1.3.1
# RUN cabal install -v hoogle-5.0.18.3
# RUN cabal install -v liquidhaskell-0.8.10.2

# Generate hoogle db
# RUN hoogle generate && stack hoogle

# Set up the dependencies for Ampersand
# RUN cd /workspaces/Ampersand && stack build --dependencies-only .
# create a `binbin` directory, that contains the executables themselves. In .cabal/bin most (all?) files are symbolic links
RUN mkdir ${WDIR}/.cabal/binbin && \
cp -L ${WDIR}/.cabal/bin/* ${WDIR}/.cabal/binbin

FROM base as dev
COPY --from=tools ${WDIR}/.cabal/binbin ${WDIR}/.cabal/bin
ENV PATH="${WDIR}/.cabal/bin:${WDIR}/.ghcup/bin:${WDIR}/.local/bin:${PATH}"

# # Add just the .cabal file to capture dependencies
COPY ./package.yaml ${WDIR}/package.yaml
COPY ./stack.yaml ${WDIR}/stack.yaml

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

ENV DEBIAN_FRONTEND=dialog

Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DevContainer for Haskell (GHC, Stack, Cabal, HIE, LSP, DAP, etc.)",
"remoteUser": "vscode",
"name": "DevContainer for Ampersand",
// "remoteUser": "root",
"runArgs": [],
"build": {
"context": "..",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cabal.sandbox.config
.cabal-sandbox
.dist-buildwrapper
/dist
/dist-newstyle
.idea
.ampersand

Expand Down
6 changes: 3 additions & 3 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Release notes of Ampersand

## Unreleased changes
* [Issue #1419] added a test, to be activated in the regression after resolving #1419.
* [Issue #1420] added a test, to be activated in the regression after resolving #1420.
- Added easier development through Docker image at dockerhub: [ampersandtarski/ampersand-devcontainer](https://hub.docker.com/repository/docker/ampersandtarski/ampersand-devcontainer/general)
* [Issue #1419](https://github.com/AmpersandTarski/Ampersand/issues/1419) added a test, to be activated in the regression after resolving #1419.
* [Issue #1420](https://github.com/AmpersandTarski/Ampersand/issues/1420) added a test, to be activated in the regression after resolving #1420.
* [Issue #1421](https://github.com/AmpersandTarski/Ampersand/issues/1421) added easier development through Docker image at dockerhub: [ampersandtarski/ampersand-devcontainer](https://hub.docker.com/repository/docker/ampersandtarski/ampersand-devcontainer/general). Also fixes https://github.com/AmpersandTarski/Ampersand/issues/1359

## v4.7.6 (26 february 2023)

Expand Down

0 comments on commit 1f24feb

Please sign in to comment.