Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP: parallel builds for erd #175

Closed
wants to merge 1 commit into from

Conversation

dduportal
Copy link
Contributor

Signed-off-by: Damien Duportal [email protected]

Signed-off-by: Damien Duportal <[email protected]>
Base automatically changed from master to main January 29, 2021 13:43
@reitzig
Copy link
Contributor

reitzig commented Feb 17, 2021

For a multi-stage build, you need to know very well what you need to copy on: in the most simple case it's a single binary, but there's no limit to the meh (I've build images with natively compiled Ruby gems, nightmare that ...).

I don't know enough about the intent of #166 and erd to gauge where we land here. @sapientpants might know more about what the actually required stuff is.

@reitzig
Copy link
Contributor

reitzig commented Feb 17, 2021

It seems that cabal does indeed provide a single binary for erd here. At least, with

# This part unchanged
FROM alpine:3.13 AS erd
RUN apk add --no-cache --virtual .haskellmakedepends \
    alpine-sdk \
    cabal \
    ghc-dev \
    ghc \
    gmp-dev \
    gnupg \
    libffi-dev \
    linux-headers \
    perl-utils \
    wget \
    xz \
    zlib-dev \
  && cabal v2-update \
  && cabal v2-install erd

FROM alpine:3.13

RUN apk add --no-cache libffi gmp graphviz
COPY --from=erd root/.cabal/bin/erd /bin/

I get this:

$ docker run --rm -it adoc-test erd --version
erd-0.2.1.0 UNKNOWN

Haven't tested any actual functionality of erd, though.

That's a lot smaller:

image

If that would help even more, they document how to build a statically-linked binary; that's beyond my involvement with Haskell tooling, though. :'D

FWIW, the largest intermediate layer I get from this build is over 3GB large. (And the build runs for a loooong time.) Wow. Anyway, point is @sapientpants did do something to drop over half of that. :)
IMHO, if somebody contributed an apk package for erd, that would be the best fix.

@dduportal dduportal changed the title WiP: parallel builds WiP: parallel builds for erd Feb 18, 2021
@dduportal
Copy link
Contributor Author

As a starting point, the native APK package for shellcheck is a good example (as it is built with cabal as well): https://pkgs.alpinelinux.org/package/edge/community/x86_64/shellcheck

@reitzig
Copy link
Contributor

reitzig commented Feb 22, 2021

@dduportal Do you have enough information to work on this?
I for one might be able to propose a new Dockerfile, but as I said, I won't be able to do any serious testing.

I'll note that multi-stage builds might also be able to reduce the size impact of building Ruby and Python dependencies, which currently happens with RUNs very similar to the new Haskell one.

@dduportal
Copy link
Contributor Author

Hello @reitzig , even though I have all the informations, my bandwidth is full until mid-March so I won't be able to work on this topic until then.

Please feel free to open a PR if you feel ok to contribute, that would be a great help!
Regarding the tests, there is a test harness (look at https://github.com/asciidoctor/docker-asciidoctor#how-to-build-and-test) so you should feel safe to change things. Do not worry: I'll have time to review the PR, and if we break something, we'll be able to quickly fix it afterwards, don't be scared as we won't release until we both feel ok (the impact will be on the DockerIimage latest in the worst case scenario, which is not aimed to be stable).

Thanks a lot for your willingness, time and efforts!

@reitzig
Copy link
Contributor

reitzig commented Feb 23, 2021

Cool! Here you go, that should get you started: #184

@dduportal
Copy link
Contributor Author

Closing in favor of #184

@dduportal dduportal closed this Feb 23, 2021
@dduportal dduportal deleted the optimize-erd branch February 23, 2021 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants