blob: bfb7399b064beb6d892e50c80b2cd0e47bc1d8c8 [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
Marc Kupietzb2c47d12026-06-16 16:22:41 +020029RUN cpm install --show-build-log-on-failure --test -g File::ShareDir::Install
Marc Kupietz9452d322025-12-12 16:42:50 +010030
Marc Kupietzb2c47d12026-06-16 16:22:41 +020031# Install runtime Perl module dependencies from Makefile.PL
32RUN cpm install --show-build-log-on-failure --test -g \
Marc Kupietz9452d322025-12-12 16:42:50 +010033 File::ShareDir \
34 File::Share \
35 XML::CompactTree::XS \
36 XML::LibXML::Reader \
37 IO::Compress::Zip \
38 IO::Uncompress::Unzip \
39 Log::Any \
Marc Kupietzb2c47d12026-06-16 16:22:41 +020040 Time::Progress
41
42# XML::Loy is only needed by the bundled test helpers. Do not run its
43# upstream test suite during the production image build.
44RUN cpm install --show-build-log-on-failure -g XML::Loy
Marc Kupietz9452d322025-12-12 16:42:50 +010045
46# Run Makefile.PL and install (this will install share files properly)
47RUN perl Makefile.PL && make install
48
49# Remove all build dependencies to reduce image size
50RUN rm /bin/cpm && \
51 apk del git \
52 perl-dev \
53 perl-doc \
54 g++ \
55 wget \
56 libxml2-dev \
57 curl && \
58 rm -rf /root/.cpanm \
59 /usr/local/share/man
60
61# Create non-root user for security
62RUN addgroup -S korap && \
63 adduser -S tei2korapxml -G korap && \
64 chown -R tei2korapxml:korap /tei2korapxml
65
66USER tei2korapxml
67
68# Set up entrypoint
69COPY docker-entrypoint.sh /usr/local/bin/
70ENTRYPOINT ["docker-entrypoint.sh"]
71
72# Default command shows help
73CMD ["--help"]
74
75LABEL description="Docker Image for tei2korapxml - TEI P5 to KorAP-XML converter"
76LABEL maintainer="korap@ids-mannheim.de"
77LABEL repository="https://github.com/KorAP/KorAP-XML-TEI"
78
79# Build command:
80# docker build -f Dockerfile -t korap/tei2korapxml:x.xx-large .
81
82# Slimming with mintoolkit/mint (https://github.com/mintoolkit/mint):
83# mint build --http-probe=false \
84# --exec="tei2korapxml --version" \
85# --include-workdir=true \
86# --include-path="/usr/local/share/perl5/site_perl/KorAP/" \
87# --tag korap/tei2korapxml:x.xx \
88# --tag korap/tei2korapxml:latest \
89# korap/tei2korapxml:x.xx-large