Skip to content

Reduces image size of resulting Docker Perl image #53

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 5.008.009-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.8.9.tar.bz2 -o perl-5.8.9.tar.b
WORKDIR /root

CMD ["perl5.8.9","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.008.009-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.8.9.tar.bz2 -o perl-5.8.9.tar.b
WORKDIR /root

CMD ["perl5.8.9","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.010.001-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.10.1.tar.bz2 -o perl-5.10.1.tar
WORKDIR /root

CMD ["perl5.10.1","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.010.001-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.10.1.tar.bz2 -o perl-5.10.1.tar
WORKDIR /root

CMD ["perl5.10.1","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.012.005-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.12.5.tar.bz2 -o perl-5.12.5.tar
WORKDIR /root

CMD ["perl5.12.5","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.012.005-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.12.5.tar.bz2 -o perl-5.12.5.tar
WORKDIR /root

CMD ["perl5.12.5","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.014.004-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.14.4.tar.bz2 -o perl-5.14.4.tar
WORKDIR /root

CMD ["perl5.14.4","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.014.004-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.14.4.tar.bz2 -o perl-5.14.4.tar
WORKDIR /root

CMD ["perl5.14.4","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.016.003-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.16.3.tar.bz2 -o perl-5.16.3.tar
WORKDIR /root

CMD ["perl5.16.3","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.016.003-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.16.3.tar.bz2 -o perl-5.16.3.tar
WORKDIR /root

CMD ["perl5.16.3","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.018.004-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.18.4.tar.bz2 -o perl-5.18.4.tar
WORKDIR /root

CMD ["perl5.18.4","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.018.004-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:jessie as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.18.4.tar.bz2 -o perl-5.18.4.tar
WORKDIR /root

CMD ["perl5.18.4","-de0"]

FROM debian:jessie-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.020.003-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.20.3.tar.bz2 -o perl-5.20.3.tar
WORKDIR /root

CMD ["perl5.20.3","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.020.003-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.20.3.tar.bz2 -o perl-5.20.3.tar
WORKDIR /root

CMD ["perl5.20.3","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.022.004-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.22.4.tar.bz2 -o perl-5.22.4.tar
WORKDIR /root

CMD ["perl5.22.4","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.022.004-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.22.4.tar.bz2 -o perl-5.22.4.tar
WORKDIR /root

CMD ["perl5.22.4","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.024.004-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.24.4.tar.bz2 -o perl-5.24.4.tar
WORKDIR /root

CMD ["perl5.24.4","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.024.004-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.24.4.tar.bz2 -o perl-5.24.4.tar
WORKDIR /root

CMD ["perl5.24.4","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.026.002-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.26.2.tar.bz2 -o perl-5.26.2.tar
WORKDIR /root

CMD ["perl5.26.2","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.026.002-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.26.2.tar.bz2 -o perl-5.26.2.tar
WORKDIR /root

CMD ["perl5.26.2","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.028.000-64bit,threaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.28.0.tar.xz -o perl-5.28.0.tar.
WORKDIR /root

CMD ["perl5.28.0","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion 5.028.000-64bit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM buildpack-deps:stretch as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -25,3 +25,10 @@ RUN curl -SL https://www.cpan.org/src/5.0/perl-5.28.0.tar.xz -o perl-5.28.0.tar.
WORKDIR /root

CMD ["perl5.28.0","-de0"]

FROM debian:stretch-slim as runtime
WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]
9 changes: 8 additions & 1 deletion generate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ =head1 DESCRIPTION
=cut

__DATA__
FROM buildpack-deps:{{_tag}}
FROM buildpack-deps:{{_tag}} as build
LABEL maintainer="Peter Martini <[email protected]>, Zak B. Elep <[email protected]>"

COPY *.patch /usr/src/perl/
Expand All @@ -222,3 +222,10 @@ =head1 DESCRIPTION
WORKDIR /root

CMD ["perl{{version}}","-de0"]

FROM debian:{{_tag}}-slim as runtime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in docker-library/official-images#3383 (comment) we end up with

  • having to make builds at least twice per version/architecture
  • a less-transparent dependency between the build base image and the runtime (unless we use the exact image layer ids here; @yosifkit @tianon can probably elaborate more)

I'm thinking of doing something similar to what https://github.com/travis-perl does (have prebuilts in a repo under here which we can fetch from the bashbrew builds) but I'm not sure if that's a correct (or supported) approach...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure I follow all the comments (of #3383). As to your two remaining points

  • The two builds should be fairly quick as they make use of the cache.
  • You could also make a build-image based on debian:-slim.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the second point is what we're exploring now in #52; I'll have a PR and perhaps a few demo images up on my own Docker Hub namespace for people to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have something, I'd be happy to test this. Just let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've just pushed #54, please try it out! I've triggered builds for 5.28-slim and 5.28-slim-threaded in my own hub repo, though its taking a while so it might be better to build these locally :)

WORKDIR /root
COPY --from=build /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=build /usr/local/bin /usr/local/bin/

CMD ["perl5.26.2","-de0"]