# NOTE: This hash is pinned to avoid version and environment differences.
FROM httpd:2.4.68

RUN apt update && apt install -y python3 && rm -rf /var/lib/apt/lists/*

# Enable CGI
RUN sed -i 's/^\t#LoadModule cgid_module modules\/mod_cgid\.so/LoadModule cgid_module modules\/mod_cgid.so/' /usr/local/apache2/conf/httpd.conf
# Request to / should run greeting.cgi as CGI
RUN echo '\nScriptAlias / "/usr/local/apache2/cgi-bin/greeting.cgi/"' >> /usr/local/apache2/conf/httpd.conf

COPY greeting.cgi /usr/local/apache2/cgi-bin/greeting.cgi
RUN chmod +x /usr/local/apache2/cgi-bin/greeting.cgi