# AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
# This Dockerfile is generated by docker/BUILD
# To make changes, modify the build_perl() function in docker/BUILD

# Stage 1: Build environment
FROM ubuntu:24.04 AS builder

ENV TERM=xterm
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3008
RUN apt-get update && apt-get -y --no-install-recommends install \
    gcc \
    libc6-dev \
    libssl-dev \
    make \
    wget \
    zlib1g-dev \
  && rm -rf /var/lib/apt/lists/*

RUN wget --progress=dot:giga http://www.cpan.org/src/5.0/perl-5.42.0.tar.gz \
    -O - | tar xzf - -C /usr/local/src

WORKDIR /usr/local/src/perl-5.42.0
RUN ./Configure -des -Doptimize='-O2' && make install

# Strip debug symbols from binaries
RUN find /usr/local -type f -executable -exec strip --strip-unneeded {} \; \
    2>/dev/null || true

# Stage 2: Runtime environment
FROM ubuntu:24.04

ENV TERM=xterm
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install minimal build tools for CPAN module compilation
# hadolint ignore=DL3008
RUN apt-get update && apt-get -y --no-install-recommends install \
    gcc \
    libc6-dev \
    make \
  && rm -rf /var/lib/apt/lists/*

# Copy only the installed Perl - no build tools, no source
COPY --from=builder /usr/local /usr/local

ENV PATH="/usr/local/bin:${PATH}"
