Skip to content

Commit

Permalink
Use ghc bindists
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Aug 14, 2023
1 parent c07e1e1 commit 2f75371
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down
43 changes: 43 additions & 0 deletions ghc-Dockerfile
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
GHC_VERSION := "9.2.8"
TAG_VERSION := "v1"

# List all recipies
default:
just --list --unsorted

# 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:
Expand All @@ -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

0 comments on commit 2f75371

Please sign in to comment.