Skip to content

Multiplatform GHC 9.8 image #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,40 @@ jobs:

strategy:
matrix:
ghc-version:
- ghc-8.8.4
- ghc-8.10.7
- ghc-9.0.2
- ghc-9.4.7
- ghc-9.4.8
- ghc-9.8.2
include:
- ghc-version: ghc-8.8.4
platform: linux/amd64
- ghc-version: ghc-8.10.7
platform: linux/amd64
- ghc-version: ghc-9.0.2
platform: linux/amd64
- ghc-version: ghc-9.4.7
platform: linux/amd64
- ghc-version: ghc-9.4.8
platform: linux/amd64
- ghc-version: ghc-9.8.2
platform: linux/amd64,linux/arm64

steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build image
run: docker build ./${{ matrix.ghc-version }} --tag $IMAGE_NAME:${{ matrix.ghc-version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u fossabot --password-stdin
- uses: actions/checkout@v2

- name: Push image
- name: Login to Docker Hub
if: ${{ github.ref == 'refs/heads/master' }}
run: docker push $IMAGE_NAME:${{ matrix.ghc-version }}
uses: docker/login-action@v3
with:
username: fossabot
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
file: ${{ format('./{0}/Dockerfile', matrix.ghc-version) }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ format('{0}:{1}', env.IMAGE_NAME, matrix.ghc-version) }}
43 changes: 36 additions & 7 deletions ghc-9.8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,45 @@ RUN apk --no-cache add binutils-gold curl gcc g++ git gmp-dev ncurses-dev ncurse
# Install system deps for FOSSA CLI:
RUN apk --no-cache add bash xz-libs xz-dev bzip2-dev bzip2-static upx curl jq

ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=1
ENV BOOTSTRAP_HASKELL_MINIMAL=1
ENV GHC_VERSION="9.8.2"

ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

# Delete the documentation, we don't really need it.
RUN ghcup install ghc 9.8.2 && rm -rf "$HOME/.ghcup/share/doc/*"
# There aren't official builds of ghcup that are built against musl for aarch64.
# So the following two steps do the install manually on that platform.
# They manually do the same steps that ghcup would.
# ghcup should have support for this soon: https://github.com/haskell/ghcup-hs/issues/1012#issuecomment-2294829976
# When that happens, you should be able to remove the 'else' branches and have the install work for all platforms.
RUN <<EOF
if [ $(uname -m) != "aarch64" ] ; then
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
export BOOTSTRAP_HASKELL_MINIMAL=1
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

ghcup install ghc "$GHC_VERSION"
ghcup set ghc "$GHC_VERSION"
else
mkdir /tmp/ghc
curl "https://downloads.haskell.org/~ghc/$GHC_VERSION/ghc-$GHC_VERSION-aarch64-alpine3_18-linux.tar.xz" | tar --strip-components=1 -xJC /tmp/ghc
cd /tmp/ghc
./configure --prefix="$HOME/.ghcup" && make install && rm -rf /tmp/ghc
fi

# Docs take up a lot of space in the image and aren't really necessary.
rm -rf "$HOME/.ghcup/share/doc"

EOF

RUN ghcup set ghc 9.8.2
RUN ghcup install cabal 3.10.3.0
# Install cabal
RUN <<EOF
if [ $(uname -m) != "aarch64" ] ; then
ghcup install cabal 3.10.3.0
else
curl https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.10.3.0/cabal-install-3.10.3.0-aarch64-alpine3_20.tar.xz | tar -xJC "$HOME/.ghcup/bin/"
chmod 755 "$HOME/.ghcup/bin/cabal"
rm "$HOME/.ghcup/bin/plan.json"
fi
EOF

# Sets USER environment to overcome issue, as described in:
# https://github.com/cachix/install-nix-action/issues/122
Expand Down
Loading