# 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.

# "ubuntu" is the latest LTS release.  "ubuntu:rolling" is the latest release.
# Either might lag behind; as of 2024-11-16, ubuntu:rolling was still 24.04 rather than 24.10.
FROM ubuntu
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.

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install locales \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen "en_US.UTF-8"
ENV LANG=en_US.UTF-8 \
    LANGUAGE=en_US:en \
    LC_ALL=en_US.UTF-8

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install \
  apt-utils

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install \
  autoconf \
  automake \
  bc \
  binutils-dev \
  curl \
  gcc \
  git \
  jq \
  lsb-release \
  m4 \
  make \
  rsync \
  unzip \
  wget

# Install the JDK.
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install \
  openjdk-8-jdk \
&& update-java-alternatives --set java-1.8.0-openjdk-amd64

# These are needed to build the Checker Framework, used by the "typecheck" job in CI.
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install \
  ant \
  maven \
  python3

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -qqy install \
  devscripts \
  g++ \
  graphviz \
  libc6-dbg \
  netpbm \
  python3-setuptools \
  shellcheck \
  shfmt \
  texinfo \
  texlive \
  texlive-latex-extra \
  universal-ctags \
  yamllint \
  zlib1g-dev

# 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 export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy update \
&& apt -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 export DEBIAN_FRONTEND=noninteractive \
&& 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 export DEBIAN_FRONTEND=noninteractive \
&& apt -qqy autoremove \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
