| 1 |
# Dockerfile by Sébastien HOUZÉ, https://github.com/shouze |
| 2 |
FROM perl:slim AS builder |
| 3 |
|
| 4 |
RUN export DEBIAN_FRONTEND=noninteractive \ |
| 5 |
&& apt-get update \ |
| 6 |
&& apt-get install -y --no-install-recommends \ |
| 7 |
dos2unix \ |
| 8 |
gcc |
| 9 |
|
| 10 |
#Install all dependencies |
| 11 |
RUN cpanm \ |
| 12 |
Algorithm::Diff \ |
| 13 |
Digest::MD5 \ |
| 14 |
Parallel::ForkManager \ |
| 15 |
Regexp::Common |
| 16 |
|
| 17 |
#Copy source code |
| 18 |
COPY cloc /usr/src/ |
| 19 |
RUN find /usr/src/ -type f -exec dos2unix {} \; |
| 20 |
|
| 21 |
FROM perl:slim AS base |
| 22 |
|
| 23 |
RUN export DEBIAN_FRONTEND=noninteractive \ |
| 24 |
&& apt-get update \ |
| 25 |
&& apt-get install -y --no-install-recommends \ |
| 26 |
git \ |
| 27 |
unzip \ |
| 28 |
&& rm -rf /var/lib/apt/lists/* |
| 29 |
|
| 30 |
#Copy dependencies and source prepared in base image |
| 31 |
COPY --from=builder /usr/local/lib/perl5 /usr/local/lib/perl5 |
| 32 |
COPY --from=builder /usr/src/ /usr/src/ |
| 33 |
|
| 34 |
#################### |
| 35 |
FROM base AS test |
| 36 |
|
| 37 |
RUN export DEBIAN_FRONTEND=noninteractive \ |
| 38 |
&& apt-get update \ |
| 39 |
&& apt-get install -y --no-install-recommends \ |
| 40 |
ca-certificates |
| 41 |
|
| 42 |
#Copy test code |
| 43 |
COPY .git /usr/src/.git |
| 44 |
COPY tests /usr/src/tests |
| 45 |
COPY Unix /usr/src/Unix |
| 46 |
|
| 47 |
WORKDIR /usr/src/Unix |
| 48 |
|
| 49 |
#Checkout of cloc_submodule_test for t/02_git.t tests |
| 50 |
RUN git clone https://github.com/AlDanial/cloc_submodule_test.git |
| 51 |
|
| 52 |
#Run tests |
| 53 |
RUN make test |
| 54 |
|
| 55 |
#################### |
| 56 |
FROM base AS final |
| 57 |
|
| 58 |
WORKDIR /tmp |
| 59 |
|
| 60 |
ENTRYPOINT ["/usr/src/cloc"] |
| 61 |
CMD ["--help"] |