content: # FIXME: z3.4.8.5-1 can no longer be installed on Ubuntu 24.04 because python3-distutils disappeared, and the z3 opam package has not been fixed for version 4.8.5, and 23.10 and all prior non-LTS are now EOL. Reverting to the previous LTS
  FROM ubuntu:22.04
  
  SHELL ["/bin/bash", "-c"]
  
  # Base dependencies: opam
  # CI dependencies: jq (to identify F* branch)
  # python3 (for interactive tests)
  RUN apt-get update \
      && apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        wget \
        git \
        gnupg \
        sudo \
        python3 \
        python-is-python3 \
        libgmp-dev \
        pkg-config \
        opam \
      && apt-get clean -y
  # FIXME: libgmp-dev should be installed automatically by opam,
  # but it is not working, so just adding it above.
  
  # Create a new user and give them sudo rights
  ARG USER=vscode
  RUN useradd -d /home/$USER -s /bin/bash -m $USER
  RUN echo "$USER ALL=NOPASSWD: ALL" >> /etc/sudoers
  USER $USER
  ENV HOME /home/$USER
  WORKDIR $HOME
  RUN mkdir -p $HOME/bin
  
  # Make sure ~/bin is in the PATH
  RUN echo 'export PATH=$HOME/bin:$PATH' | tee --append $HOME/.profile $HOME/.bashrc $HOME/.bash_profile
  
  # Install Z3
  COPY ./bin/get_fstar_z3.sh /usr/local/bin
  RUN get_fstar_z3.sh ~/bin
  
  # Install dotnet
  ENV DOTNET_ROOT /home/$USER/dotnet
  RUN wget -nv https://download.visualstudio.microsoft.com/download/pr/cd0d0a4d-2a6a-4d0d-b42e-dfd3b880e222/008a93f83aba6d1acf75ded3d2cfba24/dotnet-sdk-6.0.400-linux-x64.tar.gz && \
      mkdir -p $DOTNET_ROOT && \
      tar xf dotnet-sdk-6.0.400-linux-x64.tar.gz -C $DOTNET_ROOT && \
      echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' | tee --append $HOME/.profile $HOME/.bashrc $HOME/.bash_profile && \
      rm -f dotnet-sdk*.tar.gz
  
  # Install OCaml
  ARG OCAML_VERSION=4.14.2
  RUN opam init --compiler=$OCAML_VERSION --disable-sandboxing
  RUN opam option depext-run-installs=true
  ENV OPAMYES=1
  COPY ./fstar.opam .
  RUN opam install --deps-only . && rm fstar.opam
  
  WORKDIR $HOME
  
  # Instrument .bashrc to set the opam switch. Note that this
  # just appends the *call* to eval $(opam env) in these files, so we
  # compute the new environments fter the fact. Calling opam env here
  # would perhaps thrash some variables set by the devcontainer infra.
  RUN echo 'eval $(opam env --set-switch)' | tee --append $HOME/.profile $HOME/.bashrc $HOME/.bash_profile
  