Skip to content

Commit

Permalink
Refactor the Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Aug 7, 2024
1 parent 788ea7d commit ee641b5
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# this is a pinned ubuntu:22.04 (newer versions have incomptible
# library versions for souffle)
FROM ubuntu@sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21

ARG GID=1000
ARG UID=1000

Expand All @@ -15,6 +11,12 @@ ARG GHCID_VERSION=0.8.9
ARG GHC_TAGS_VERSION=1.9
ARG POSTGRESQL_MIGRATION_VERSION=0.2.1.8

# this is a pinned ubuntu:22.04 (newer versions have incomptible
# library versions for souffle)
FROM ubuntu@sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21 AS base
ARG USER ${USER}
ARG GID
ARG UID
# generate a working directory
USER "root"
ARG USER="local"
Expand All @@ -32,6 +34,7 @@ WORKDIR /flora-server
RUN apt update && \
apt install -y build-essential curl libffi-dev libffi8 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 git libsodium-dev pkg-config

FROM base AS ghcup
# install dependencies (pg_config, postgresql-client, yarn)
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE="YES"
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK="YES"
Expand All @@ -52,8 +55,8 @@ RUN ghcup install hls $HLS_VERSION \
&& ghcup set ghc $GHC_VERSION \
&& ghcup install cabal $CABAL_VERSION

USER ${USER}

FROM base AS souffle
# install soufflé
USER "root"
RUN wget --content-disposition https://github.com/souffle-lang/souffle/releases/download/2.2/x86_64-ubuntu-2004-souffle-2.2-Linux.deb
Expand All @@ -62,23 +65,38 @@ USER ${USER}

RUN echo $PATH

# install Haskell tooling (note that for cabal, it's probably better
# to run `cabal update` as separate step, as cabal doesn't delete
# package versions)
FROM ghcup AS haskell-tools

USER ${USER}

ARG APPLY_REFACT_VERSION
ARG CABAL_FMT_VERSION
ARG CABAL_VERSION
ARG FOURMOLU_VERSION
ARG GHCID_VERSION
ARG GHC_TAGS_VERSION
ARG HLINT_VERSION
ARG POSTGRESQL_MIGRATION_VERSION

RUN cabal update
RUN cabal install -j postgresql-migration-$POSTGRESQL_MIGRATION_VERSION
RUN cabal install -j hlint-$HLINT_VERSION
RUN cabal install -j apply-refact-$APPLY_REFACT_VERSION
RUN cabal install -j fourmolu-$FOURMOLU_VERSION
RUN cabal install -j cabal-fmt-$CABAL_FMT_VERSION
RUN cabal install -j fourmolu-$FOURMOLU_VERSION
RUN cabal install -j ghcid-$GHCID_VERSION
RUN cabal install -j ghc-tags-$GHC_TAGS_VERSION
RUN cabal install -j hlint-$HLINT_VERSION
RUN cabal install -j postgresql-migration-$POSTGRESQL_MIGRATION_VERSION

FROM base AS shell-config
# configure the shell

USER ${USER}

RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
COPY --chown=${USER} scripts/shell-welcome.txt /etc/motd
COPY --chown=${USER} scripts/.zshrc /home/$USER/.zshrc

FROM ghcup AS server
# build Haskell dependencies
COPY --chown=${USER} cabal.project flora.cabal cabal.project.freeze ./
RUN cabal build --only-dependencies -j
Expand Down

0 comments on commit ee641b5

Please sign in to comment.