blob: b817149c6b3a3faa9eb3c14b7d2ae6408044aa09 [file] [log] [blame]
Marc Kupietz9452d322025-12-12 16:42:50 +01001# Use alpine linux as base image
2FROM alpine:latest AS tei2korapxml
3
4RUN apk update && \
5 apk add --no-cache git \
6 perl \
7 perl-io-socket-ssl \
8 perl-dev \
9 g++ \
10 make \
11 wget \
12 perl-doc \
13 libxml2-dev \
14 perl-xml-libxml \
15 perl-module-pluggable \
16 openjdk21-jre \
17 curl && \
18 set -o pipefail
19
20# Install cpm (faster CPAN module installer)
21RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm
22
23# Copy repository respecting .dockerignore
24COPY . /tei2korapxml
25
26WORKDIR /tei2korapxml
27
28# Install build-time dependencies required by Makefile.PL
29RUN cpm install --test -g File::ShareDir::Install
30
31# Install all Perl module dependencies from Makefile.PL
32RUN cpm install --test -g \
33 File::ShareDir \
34 File::Share \
35 XML::CompactTree::XS \
36 XML::LibXML::Reader \
37 IO::Compress::Zip \
38 IO::Uncompress::Unzip \
39 Log::Any \
40 Time::Progress \
41 XML::Loy
42
43# Run Makefile.PL and install (this will install share files properly)
44RUN perl Makefile.PL && make install
45
46# Remove all build dependencies to reduce image size
47RUN rm /bin/cpm && \
48 apk del git \
49 perl-dev \
50 perl-doc \
51 g++ \
52 wget \
53 libxml2-dev \
54 curl && \
55 rm -rf /root/.cpanm \
56 /usr/local/share/man
57
58# Create non-root user for security
59RUN addgroup -S korap && \
60 adduser -S tei2korapxml -G korap && \
61 chown -R tei2korapxml:korap /tei2korapxml
62
63USER tei2korapxml
64
65# Set up entrypoint
66COPY docker-entrypoint.sh /usr/local/bin/
67ENTRYPOINT ["docker-entrypoint.sh"]
68
69# Default command shows help
70CMD ["--help"]
71
72LABEL description="Docker Image for tei2korapxml - TEI P5 to KorAP-XML converter"
73LABEL maintainer="korap@ids-mannheim.de"
74LABEL repository="https://github.com/KorAP/KorAP-XML-TEI"
75
76# Build command:
77# docker build -f Dockerfile -t korap/tei2korapxml:x.xx-large .
78
79# Slimming with mintoolkit/mint (https://github.com/mintoolkit/mint):
80# mint build --http-probe=false \
81# --exec="tei2korapxml --version" \
82# --include-workdir=true \
83# --include-path="/usr/local/share/perl5/site_perl/KorAP/" \
84# --tag korap/tei2korapxml:x.xx \
85# --tag korap/tei2korapxml:latest \
86# korap/tei2korapxml:x.xx-large