|
| 1 | +# This is the layer that can run things |
| 2 | +FROM debian:buster |
| 3 | +LABEL maintainer= "Deriv Services Ltd. <[email protected]>" |
| 4 | + |
| 5 | +# Some standard server-like config used everywhere |
| 6 | +ENV TZ=UTC |
| 7 | +ENV DEBIAN_FRONTEND=noninteractive |
| 8 | +ENV PERL_VERSION=5.32.0 |
| 9 | +ENV PERL_SHA256=6f436b447cf56d22464f980fac1916e707a040e96d52172984c5d184c09b859b |
| 10 | +ENV CPANM_VERSION=1.7044 |
| 11 | +ENV CPANM_SHA256=9b60767fe40752ef7a9d3f13f19060a63389a5c23acc3e9827e19b75500f81f3 |
| 12 | + |
| 13 | +# Use an apt-cacher-ng or similar proxy when available during builds |
| 14 | +ARG DEBIAN_PROXY |
| 15 | + |
| 16 | +WORKDIR /usr/src/perl |
| 17 | + |
| 18 | +RUN [ -n "$DEBIAN_PROXY" ] \ |
| 19 | + && (echo "Acquire::http::Proxy \"http://$DEBIAN_PROXY\";" > /etc/apt/apt.conf.d/30proxy) \ |
| 20 | + && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \ |
| 21 | + || echo "No local Debian proxy configured" \ |
| 22 | + && apt-get update \ |
| 23 | + && apt-get dist-upgrade -y -q --no-install-recommends \ |
| 24 | + && apt-get install -y -q --no-install-recommends \ |
| 25 | + git openssh-client curl socat ca-certificates gcc make libc6-dev libssl-dev zlib1g-dev xz-utils dumb-init \ |
| 26 | + && curl -SL https://www.cpan.org/src/5.0/perl-${PERL_VERSION}.tar.xz -o perl-${PERL_VERSION}.tar.xz \ |
| 27 | + && echo "${PERL_SHA256} *perl-${PERL_VERSION}.tar.xz" | sha256sum -c - \ |
| 28 | + && tar --strip-components=1 -xaf perl-${PERL_VERSION}.tar.xz -C /usr/src/perl \ |
| 29 | + && rm perl-${PERL_VERSION}.tar.xz \ |
| 30 | + && ./Configure -Duse64bitall -Duseshrplib -Dprefix=/opt/perl-${PERL_VERSION} -Dman1dir=none -Dman3dir=none -des \ |
| 31 | + && make -j$(nproc) \ |
| 32 | + && make install \ |
| 33 | + && cd /usr/src \ |
| 34 | + && curl -LO https://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-${CPANM_VERSION}.tar.gz \ |
| 35 | + && echo "${CPANM_SHA256} *App-cpanminus-${CPANM_VERSION}.tar.gz" | sha256sum -c - \ |
| 36 | + && tar -xzf App-cpanminus-${CPANM_VERSION}.tar.gz \ |
| 37 | + && rm App-cpanminus-${CPANM_VERSION}.tar.gz \ |
| 38 | + && cd App-cpanminus-${CPANM_VERSION} && /opt/perl-${PERL_VERSION}/bin/perl bin/cpanm . \ |
| 39 | + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ |
| 40 | + && rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/App-cpanminus-${CPANM_VERSION}* /tmp/* \ |
| 41 | +# Locale support is probably quite useful in some cases, but |
| 42 | +# let's let individual builds decide that via aptfile config |
| 43 | +# && echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen \ |
| 44 | +# && locale-gen \ |
| 45 | + && mkdir -p /etc/ssh/ \ |
| 46 | + && ssh-keyscan github.com >> /etc/ssh/ssh_known_hosts \ |
| 47 | + && mkdir -p /app |
| 48 | + |
| 49 | +WORKDIR /app/ |
| 50 | + |
| 51 | +ENV PATH="/opt/perl-${PERL_VERSION}/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin" |
| 52 | + |
| 53 | +ONBUILD ADD cpanfile aptfile /app/ |
| 54 | + |
| 55 | +# Install everything in the aptfile first, as system deps, then |
| 56 | +# go through the CPAN deps. Once those are all done, remove anything |
| 57 | +# that we would have pulled in as a build dep (compilers, for example) |
| 58 | +# unless they happened to be in the aptfile. |
| 59 | +ONBUILD RUN if [ -s /app/aptfile ]; then \ |
| 60 | + apt-get -y -q update \ |
| 61 | + && apt-get -y -q --no-install-recommends install $(cat /app/aptfile); \ |
| 62 | + fi \ |
| 63 | + && cpanm --notest --quiet --installdeps --with-recommends . \ |
| 64 | + && apt-get purge -y -q $(perl -le'@seen{split " ", "" . do { local ($/, @ARGV) = (undef, "/app/aptfile"); <> }} = () if -r "aptfile"; print for grep { !exists $seen{$_} } qw(make gcc git openssh-client libc6-dev libssl-dev zlib1g-dev)') \ |
| 65 | + && apt-get -y --purge autoremove \ |
| 66 | + && rm -rf /var/lib/apt/lists/* /var/cache/apt/* /root/.cpanm /tmp/* |
| 67 | + |
| 68 | +ONBUILD ADD . /app/ |
| 69 | + |
| 70 | +ENTRYPOINT [ "/usr/bin/dumb-init", "--" ] |
| 71 | + |
| 72 | +CMD [ "perl", "app.pl" ] |
0 commit comments