| Marc Kupietz | 9452d32 | 2025-12-12 16:42:50 +0100 | [diff] [blame^] | 1 | # Use alpine linux as base image |
| 2 | FROM alpine:latest AS tei2korapxml |
| 3 | |
| 4 | RUN 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) |
| 21 | RUN curl -fsSL https://raw.githubusercontent.com/kupietz/cpm/main/cpm > /bin/cpm && chmod a+x /bin/cpm |
| 22 | |
| 23 | # Copy repository respecting .dockerignore |
| 24 | COPY . /tei2korapxml |
| 25 | |
| 26 | WORKDIR /tei2korapxml |
| 27 | |
| 28 | # Install build-time dependencies required by Makefile.PL |
| 29 | RUN cpm install --test -g File::ShareDir::Install |
| 30 | |
| 31 | # Install all Perl module dependencies from Makefile.PL |
| 32 | RUN 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) |
| 44 | RUN perl Makefile.PL && make install |
| 45 | |
| 46 | # Remove all build dependencies to reduce image size |
| 47 | RUN 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 |
| 59 | RUN addgroup -S korap && \ |
| 60 | adduser -S tei2korapxml -G korap && \ |
| 61 | chown -R tei2korapxml:korap /tei2korapxml |
| 62 | |
| 63 | USER tei2korapxml |
| 64 | |
| 65 | # Set up entrypoint |
| 66 | COPY docker-entrypoint.sh /usr/local/bin/ |
| 67 | ENTRYPOINT ["docker-entrypoint.sh"] |
| 68 | |
| 69 | # Default command shows help |
| 70 | CMD ["--help"] |
| 71 | |
| 72 | LABEL description="Docker Image for tei2korapxml - TEI P5 to KorAP-XML converter" |
| 73 | LABEL maintainer="korap@ids-mannheim.de" |
| 74 | LABEL 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 |