# Create a Docker image that is ready to run the full Daikon tests,
# including building the manual and Javadoc.
# But it's used primarily for running miscellaneous tests such as the manual
# and Javadoc.

FROM rockylinux:9
LABEL org.opencontainers.image.authors="Michael Ernst <mernst@cs.washington.edu>"

# According to
# https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/:
#  * Put "apt update" and "apt install" in the same RUN command.
#  * Do not run "apt upgrade"; instead get upstream to update.

# The EPEL repository contains certain packages.
RUN dnf -q -y upgrade && dnf -q -y install \
  epel-release

# curl is installed by default on Rocky Linux.
RUN dnf -q -y upgrade && dnf -q -y install \
  autoconf \
  automake \
  bc \
  binutils-devel \
  diffutils \
  findutils \
  gcc \
  git \
  jq \
  m4 \
  make \
  perl-English \
  perl-filetest \
  rsync \
  tar \
  unzip \
  wget \
  which

# Install the JDK.
RUN dnf -q -y upgrade && dnf -q -y install \
  java-17-openjdk \
  java-17-openjdk-devel

RUN dnf -q -y upgrade && dnf -q -y install \
  ctags \
  devscripts-checkbashisms \
  gcc-c++ \
  graphviz \
  netpbm \
  netpbm-progs \
  python3 \
  python3-distutils-extra \
  ShellCheck \
  texlive \
  yamllint

# Alternately, run: dnf --enablerepo=crb install PACKAGENAME
RUN dnf config-manager --set-enabled crb \
&& dnf -y install \
  dnf-plugins-core \
  texinfo \
  texinfo-tex

# Install shfmt.
RUN dnf -q -y upgrade && dnf -q -y install \
  golang \
&& go install mvdan.cc/sh/v3/cmd/shfmt@latest
ENV PATH=/root/go/bin:$PATH

# Install Python dependencies (obsolete, to be removed).
# `pipx ensurepath` only adds to the path in newly-started shells.
# BUT, setting the path for the current user is not enough.
# Azure creates a new user and runs jobs as it.
# So, install into /usr/local/bin which is already on every user's path.
RUN dnf -q -y install \
  pipx \
&& PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install mypy \
&& PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install ruff

# Install uv (manages Python dependencies).
RUN echo "installing uv" \
&& wget -qO- https://astral.sh/uv/install.sh | sh \
&& find /root -exec chmod +r {} \; \
&& find /root -type d -exec chmod +x {} \; \
&& find /root/.local/bin -type f -exec chmod +x {} \;
ENV PATH=/root/.local/bin:$PATH

# Clean up.
RUN dnf -q clean all
