Skip to content

Commit

Permalink
using stack to build ampersand
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjoosten committed Jul 1, 2023
1 parent a3f57ad commit 8aef83f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hanjoosten/ampersand-devcontainer:latest
FROM ampersandtarski/ampersand-devcontainer:latest

ENV DEBIAN_FRONTEND=dialog

Expand Down
109 changes: 14 additions & 95 deletions .devcontainer/DockerfileUpstream
Original file line number Diff line number Diff line change
@@ -1,104 +1,23 @@
FROM debian:bullseye as base
# This .devcontainer stuff is shamelessly copied from github.com/vzarytovskii/haskell-dev-env
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=16
FROM haskell:8.10

ENV USERNAME=${USERNAME} \
USER_UID=1000 \
USER_GID=1000 \
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF8
ARG WDIR=/opt/Ampersand

RUN ulimit -n 8192
WORKDIR ${WDIR}

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 stack update

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
# 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
# Docker will cache this command as a layer, freeing us up to
# modify source code without re-installing dependencies
# (unless one of the copied files changes!)
RUN stack build --only-dependencies -j4

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

FROM base as tooling

ENV GHC_VERSION=${GHC_VERSION} \
CABAL_VERSION=${CABAL_VERSION} \
STACK_VERSION=${STACK_VERSION} \
STACK_RESOLVER=${STACK_RESOLVER}

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

# 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

# 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

# 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

# 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 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 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 .
# Add and Install Application Code
COPY . ${WDIR}
RUN stack install

ENV DEBIAN_FRONTEND=dialog

Expand Down
23 changes: 0 additions & 23 deletions .devcontainer/DockerfileUpstream2

This file was deleted.

0 comments on commit 8aef83f

Please sign in to comment.