From 019db0ab91eb6a437beaa13038e4979ec2d00c7a Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 9 May 2023 15:06:12 -0400 Subject: [PATCH] DRY build.Dockerfile (#748) In addition to Don't Repeat Yourself, using ENV shows the versions used in the image history. --- build.Dockerfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build.Dockerfile b/build.Dockerfile index 133e95e0b..ff996ca0f 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -1,19 +1,24 @@ -FROM ubuntu:22.04 AS final -FROM ubuntu:22.04 AS build +ARG TAG=22.04 + +FROM ubuntu:${TAG} AS build ### Build stage # Install curl and git and smp-related dependencies RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev llvm-12 llvm-12-dev libnuma-dev +# Specify bootstrap Haskell versions +ENV BOOTSTRAP_HASKELL_GHC_VERSION=8.10.7 +ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.6.2.0 + # Install ghcup -RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_GHC_VERSION=8.10.7 BOOTSTRAP_HASKELL_CABAL_VERSION=3.6.2.0 sh +RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh # Adjust PATH ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH" # Set both as default -RUN ghcup set ghc 8.10.7 && \ +RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \ ghcup set cabal COPY . /project @@ -30,7 +35,7 @@ RUN smp=$(find ./dist-newstyle -name "smp-server" -type f -executable) && \ ### Final stage -FROM final +FROM ubuntu:${TAG} # Install OpenSSL dependency RUN apt-get update && apt-get install -y openssl libnuma-dev