From 2f7537144c3da090006caca3a27e325c7fccc50b Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Mon, 14 Aug 2023 17:09:17 +0530 Subject: [PATCH] Use ghc bindists --- .github/workflows/test.yaml | 13 +++++++++-- ghc-Dockerfile | 43 +++++++++++++++++++++++++++++++++++++ justfile | 22 +++++++++++++++---- 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 ghc-Dockerfile diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2c36d96..c01828e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,22 +27,31 @@ jobs: - uses: cachix/install-nix-action@v22 with: nix_path: nixpkgs=channel:nixos-unstable - - name: Build images + - name: Build images (Nix) shell: bash run: | set -exuo pipefail just build-nix-image just load-nix-image just build-image - - name: Test image + - name: Test image (Nix) shell: bash run: just test-image + - name: Build images (GHC official) + shell: bash + run: | + set -exuo pipefail + just build-ghc-image + - name: Test image (GHC official) + shell: bash + run: just test-ghc-image - name: Push image if: startsWith(github.ref, 'refs/tags/') shell: bash run: | set -exuo pipefail just push-image + just push-ghc-image - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') diff --git a/ghc-Dockerfile b/ghc-Dockerfile new file mode 100644 index 0000000..25b5c34 --- /dev/null +++ b/ghc-Dockerfile @@ -0,0 +1,43 @@ +FROM alpine:3.18.3 + +RUN apk upgrade --no-cache &&\ + apk add --no-cache \ + curl \ + gcc \ + git \ + libc-dev \ + xz \ + gmp-dev \ + autoconf \ + automake \ + binutils \ + build-base \ + coreutils \ + cpio \ + linux-headers \ + libffi-dev \ + musl-dev \ + zlib-dev \ + zlib-static \ + ncurses-dev \ + ncurses-libs \ + ncurses-static \ + bash \ + lld \ + shadow # for stack --docker, provides groupadd + +RUN curl -sSLo /usr/local/bin/stack https://github.com/commercialhaskell/stack/releases/download/v2.11.1/stack-2.11.1-linux-x86_64-bin && \ + chmod +x /usr/local/bin/stack + +# https://stackoverflow.com/a/41517423 +RUN ln -s /usr/lib/libncurses.a /usr/lib/libtinfo.a + +COPY stack-config.yaml /root/.stack/config.yaml + +RUN cd /tmp && \ + curl -sSLo /tmp/ghc.tar.xz https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-x86_64-alpine3.12-linux-gmp.tar.xz && \ + tar xf ghc.tar.xz && \ + cd ghc-9.2.8-x86_64-unknown-linux && \ + ./configure --prefix=/usr/local && \ + make install && \ + rm -rf /tmp/ghc.tar.xz /tmp/ghc-9.2.8-x86_64-unknown-linux diff --git a/justfile b/justfile index 48acd77..0206a2c 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,5 @@ GHC_VERSION := "9.2.8" +TAG_VERSION := "v1" # List all recipies default: @@ -6,11 +7,11 @@ default: # Build docker image build-image: - docker image build . -f Dockerfile -t ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}} + docker image build . -f Dockerfile -t ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}}{{TAG_VERSION}} # Push image push-image: - docker push ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}} + docker push ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}}{{TAG_VERSION}} # Build nix image build-nix-image: @@ -22,5 +23,18 @@ load-nix-image: # Test image test-image: - docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}} ghc --version - docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}} stack --version + docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}}{{TAG_VERSION}} ghc --version + docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:{{GHC_VERSION}}{{TAG_VERSION}} stack --version + +# Build ghc based image +build-ghc-image: + docker image build . -f ghc-Dockerfile -t ghcr.io/fpco/alpine-haskell-stack:ghc-{{GHC_VERSION}}{{TAG_VERSION}} + +# Push ghc image +push-ghc-image: + docker push ghcr.io/fpco/alpine-haskell-stack:ghc-{{GHC_VERSION}} + +# Test image +test-ghc-image: + docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:ghc-{{GHC_VERSION}}{{TAG_VERSION}} ghc --version + docker run --rm --tty ghcr.io/fpco/alpine-haskell-stack:ghc-{{GHC_VERSION}}{{TAG_VERSION}} stack --version