dream icon indicating copy to clipboard operation
dream copied to clipboard

signal handling in dockerfile

Open joprice opened this issue 3 years ago • 3 comments

When trying out one of the docker examples like example/z-docker-opam, I noticed I can't seem to stop the docker without using docker kill. Adding an entrypoint like tini launches the process as pid 1 and makes the signal handling work as expected:

RUN apk add --update libev gmp tini
...
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-muslc-amd64 /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
CMD ["/bin/app"]

(I also had to add gmp-dev in the build stage and gmp in the run stage. I assume this is due to a dependency change and I can pr this change alone to fix the image.)

joprice avatar Nov 14 '21 17:11 joprice

About the GMP issue: I think adding conf-gmp as a dependency in esy should solve it without doing anything else. If it's not enough I can find the correct resolution to make it work.

ulrikstrid avatar Nov 14 '21 17:11 ulrikstrid

For opam, I also found this tip here for installing any extra deps using opam depext:

# in builder
RUN opam depext | sed 's/-dev//' > depexts`
...
# in run
COPY --from=0 /home/opam/depexts depexts
RUN cat depexts | xargs apk add && rm -rf /var/cache/apk/*

joprice avatar Nov 14 '21 17:11 joprice

Thanks!

I won't be able to look into this immediately, but I'll be happy to merge any PRs with improvements, and in the meantime I hope this issue helps others.

aantron avatar Nov 15 '21 14:11 aantron