|
| 1 | +# First Stage: Builder |
| 2 | +FROM debian:buster-slim AS builder |
| 3 | + |
| 4 | +# Install necessary dependencies for building GHC |
| 5 | +RUN apt-get update \ |
| 6 | + && apt-get install -y --no-install-recommends \ |
| 7 | + curl build-essential libffi-dev libgmp-dev libtinfo5 ca-certificates xz-utils \ |
| 8 | + && rm -rf /var/lib/apt/lists/* |
| 9 | + |
| 10 | +# Install GHCup (Haskell toolchain manager) without automatically installing the latest GHC |
| 11 | +RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | bash -s -- -y --no-ghc \ |
| 12 | + && /root/.ghcup/bin/ghcup install ghc 8.10.7 \ |
| 13 | + && /root/.ghcup/bin/ghcup set ghc 8.10.7 \ |
| 14 | + && rm -rf /root/.ghcup/ghc/9.4.8 |
| 15 | + |
| 16 | +# Clean up unnecessary build artifacts and cache |
| 17 | +RUN rm -rf /root/.ghcup/cache /var/lib/apt/lists/* |
| 18 | + |
| 19 | + |
| 20 | +# Second Stage: Final Image |
| 21 | +FROM debian:buster-slim |
| 22 | + |
| 23 | +# Install runtime dependencies |
| 24 | +RUN apt-get update \ |
| 25 | + && apt-get install -y --no-install-recommends \ |
| 26 | + libffi6 libgmp10 libtinfo5 build-essential \ |
| 27 | + && rm -rf /var/lib/apt/lists/* |
| 28 | + |
| 29 | +# Copy GHC from the builder stage |
| 30 | +COPY --from=builder /root/.ghcup /root/.ghcup |
| 31 | + |
| 32 | +# Set PATH to include GHCup |
| 33 | +ENV PATH="/root/.ghcup/bin:${PATH}" |
| 34 | + |
| 35 | +# Set the working directory |
| 36 | +WORKDIR /usr/src/app |
| 37 | + |
| 38 | +# Install libgmp-dev explicitly for runtime linking |
| 39 | +RUN apt-get update \ |
| 40 | + && apt-get install -y --no-install-recommends libgmp-dev \ |
| 41 | + && rm -rf /var/lib/apt/lists/* |
| 42 | + |
| 43 | +# Default command to keep the container running |
| 44 | +CMD ["/bin/bash"] |
0 commit comments