ARG BASE_IMAGE=jupyter/minimal-notebook
FROM $BASE_IMAGE

ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV PATH="${PATH}:/opt/dotnet"

USER root

RUN apt-get update && \
    apt-get install -y \
        wget gpg git \
        build-essential python-dev \
        lsb-release && \
    rm -rf /var/lib/apt/lists/*

# Update the list of packages
RUN apt-get update
# Install pre-requisite packages.
RUN apt-get install -y wget apt-transport-https software-properties-common
# Create Dotnet Folder
RUN mkdir /opt/dotnet

RUN chown -R ${NB_USER}: /opt/dotnet
# Download the Microsoft repository GPG keys
RUN wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
RUN dpkg -i packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
RUN apt-get update
# Install PowerShell and .NET SDK 6.0
RUN apt-get install -y powershell dotnet-sdk-6.0

USER ${NB_USER}

# Install .NET Interactive
RUN dotnet tool install Microsoft.dotnet-interactive --tool-path /opt/dotnet

# Install  the DotNet Kernel to Jupyter VirtualEnv
RUN dotnet interactive jupyter install

USER ${NB_USER}