Skip to content
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

Alpine support #60

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

AlistairB
Copy link
Contributor

@AlistairB AlistairB commented Jan 8, 2022

#22

Testing with docker build 9.0/alpine3.15/ -t woo && docker run -it woo sh

This is blocked until 9.2.2 as 9.2.1 release appears to be broken. 9.2.2 appear to still be broken. Waiting on new release that works.

Notes

  • I had to install curl, as cabal update was failing to use the alpine wget.
  • 8.10 has a number of challenges / drawbacks and we are about to drop it. So the plan is to not include 8.10 in the alpine release.

Issues / To Do

  • Cannot CTRL + D exit from sh after exiting from ghci
  • Figure out exactly which packages should stay installed in the image + which are just needed for ghc install
  • I guess we can only support alpine 3.12 as the GHC releases are only for 3.12? (3.14 was seg faulting when I tried to load ghci) It seems 9.2.1 is just broken, but 9.0.2 and 8.10.7 will just work with newer alpine versions.
  • Set up CI.
  • Re-remove profiling files.
  • Update official tests to only use sh not bash.
  • 9.2 line segfaults for ghci. Also this issue.
  • 9.4 line also segfaults.
  • add 9.4
  • issues with new cabal and extraction method.

Pre Release

@AlistairB
Copy link
Contributor Author

Saving the 8.10 attempt before squash. The remaining issue is stack does not recognise GHC as being installed

FROM alpine:3.15

RUN apk add --no-cache \
    ca-certificates \
    curl \
    bash \
    gcc \
    git \
    g++ \
    musl-dev \
    ncurses-dev \
    libc-dev \
    libffi-dev

ARG CABAL_INSTALL=3.6.2.0
ARG CABAL_INSTALL_RELEASE_KEY=A970DF3AC3B9709706D74544B3D9F94B8DCAE210

RUN set -eux; \
    apk add --no-cache --virtual .fetch-deps gnupg; \
    cd /tmp; \
    ARCH="$(apk --print-arch)"; \
    CABAL_INSTALL_TAR="cabal-install-$CABAL_INSTALL-$ARCH-linux-alpine.tar.xz"; \
    CABAL_INSTALL_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/$CABAL_INSTALL_TAR"; \
    CABAL_INSTALL_SHA256SUMS_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS"; \
    # sha256 from https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS
    case "$ARCH" in \
        'x86_64') \
            CABAL_INSTALL_SHA256='2d3d5e4aa83aad06ed723d7038eac41271d62b56251e0a76fa35db5f902250e3'; \
            ;; \
        *) echo >&2 "error: unsupported architecture '$ARCH'"; exit 1 ;; \
    esac; \
    curl -sSL "$CABAL_INSTALL_URL" -o cabal-install.tar.gz; \
    echo "$CABAL_INSTALL_SHA256  cabal-install.tar.gz" | sha256sum -c; \
    \
    curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL"; \
    curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL.sig"; \
    GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
    gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$CABAL_INSTALL_RELEASE_KEY"; \
    gpg --batch --verify SHA256SUMS.sig SHA256SUMS; \
    # confirm we are verying SHA256SUMS that matches the release + sha256
    grep "$CABAL_INSTALL_SHA256  $CABAL_INSTALL_TAR" SHA256SUMS; \
    gpgconf --kill all; \
    \
    tar -xf cabal-install.tar.gz -C /usr/local/bin; \
    \
    rm -rf /tmp/*; \
    apk del --no-network .fetch-deps; \
    \
    cabal --version

ARG GHC=8.10.7
ARG GHC_RELEASE_KEY=88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4

RUN set -eux; \
    apk add --no-cache --virtual .fetch-deps gnupg make; \
    cd /tmp; \
    ARCH="$(apk --print-arch)"; \
    GHC_URL="https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-$ARCH-alpine3.10-linux-integer-simple.tar.xz"; \
    # sha256 from https://downloads.haskell.org/~ghc/$GHC/SHA256SUMS
    case "$ARCH" in \
        'x86_64') \
            GHC_SHA256='16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c'; \
            ;; \
        *) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \
    esac; \
    curl -sSL "$GHC_URL" -o ghc.tar.xz; \
    echo "$GHC_SHA256  ghc.tar.xz" | sha256sum -c; \
    \
    GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
    curl -sSL "$GHC_URL.sig" -o ghc.tar.xz.sig; \
    gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$GHC_RELEASE_KEY"; \
    gpg --batch --verify ghc.tar.xz.sig ghc.tar.xz; \
    gpgconf --kill all; \
    \
    tar xf ghc.tar.xz; \
    cd "ghc-$GHC-$ARCH-unknown-linux"; \
    ./configure --prefix "/opt/ghc/$GHC" --disable-ld-override; \
    make install; \
    # remove profiling support to save space
    find "/opt/ghc/$GHC/" \( -name "*_p.a" -o -name "*.p_hi" \) -type f -delete; \
    # remove some docs
    rm -rf "/opt/ghc/$GHC/share/"; \
    # for some reason the 8.10 alpine release has runghc not runhaskell
    mv "/opt/ghc/$GHC/bin/runghc" "/opt/ghc/$GHC/bin/runhaskell"; \
    \
    rm -rf /tmp/*; \
    apk del --no-network .fetch-deps; \
    \
    "/opt/ghc/$GHC/bin/ghc" --version

ARG STACK=2.7.3
ARG STACK_RELEASE_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442

RUN set -eux; \
    apk add --no-cache --virtual .fetch-deps gnupg; \
    cd /tmp; \
    ARCH="$(apk --print-arch)"; \
    STACK_URL="https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz"; \
    # sha256 from https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz.sha256
    case "$ARCH" in \
        'x86_64') \
            STACK_SHA256='a6c090555fa1c64aa61c29aa4449765a51d79e870cf759cde192937cd614e72b'; \
            ;; \
        *) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \
    esac; \
    curl -sSL "$STACK_URL" -o stack.tar.gz; \
    echo "$STACK_SHA256  stack.tar.gz" | sha256sum -c; \
    \
    curl -sSL "$STACK_URL.asc" -o stack.tar.gz.asc; \
    GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
    gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$STACK_RELEASE_KEY"; \
    gpg --batch --verify stack.tar.gz.asc stack.tar.gz; \
    gpgconf --kill all; \
    \
    tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 "stack-$STACK-linux-$ARCH/stack"; \
    stack config set system-ghc --global true; \
    stack config set install-ghc --global false; \
    \
    rm -rf /tmp/*; \
    apk del --no-network .fetch-deps; \
    \
    stack --version;

ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/${GHC}/bin:$PATH

CMD ["ghci"]

@AlistairB AlistairB force-pushed the alpine-support branch 2 times, most recently from 23cbcf9 to 46170bb Compare January 12, 2022 08:46
@AlistairB AlistairB force-pushed the alpine-support branch 3 times, most recently from 63f612a to a74e90c Compare March 10, 2022 22:26
@AlistairB AlistairB force-pushed the alpine-support branch 3 times, most recently from 356c3f2 to 557732a Compare May 28, 2022 22:33
@mbj
Copy link

mbj commented Jul 5, 2022

OT: I can reproduce a (apparently non linker segfault) under GHC 9.2.3 on both the official Alpine binaries, both bignum-native and the GMP build.

In my case GHC crashes when evaluating an runIO $ readFile "someFile" TH splice.

Currently compiling GHC head with debug symbols to nail this down a bit.

@AlistairB
Copy link
Contributor Author

Thanks @mbj for your activity on the issue. Hopefully it can be fixed, although that issue does not seem to be scheduled to be resolved in 9.2.4 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants