Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update Dockerfile to work with mybinder.org #38

Merged
merged 8 commits into from
Sep 26, 2023
103 changes: 49 additions & 54 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,85 +1,80 @@
FROM jupyter/base-notebook:latest

# Install .NET CLI dependencies

ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}

WORKDIR ${HOME}

USER root
RUN apt-get update
RUN apt-get install -y curl
ARG REPO=mcr.microsoft.com/dotnet/aspnet
FROM $REPO:7.0.11-jammy-amd64 AS dotnet-cli

ENV \
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true \
# Unset ASPNETCORE_URLS from base image
ASPNETCORE_URLS= \
# Do not generate certificate
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
# SDK version
DOTNET_SDK_VERSION=7.0.401 \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USE_POLLING_FILE_WATCHER=true \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip \
# Opt out of telemetry until after we install jupyter when building the image, this prevents caching of machine id
DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT=true
DOTNET_CLI_TELEMETRY_OPTOUT=true


# Install .NET CLI dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu66 \
libssl1.1 \
libstdc++6 \
zlib1g \
&& rm -rf /var/lib/apt/lists/*

# Install .NET Core SDK

# When updating the SDK version, the sha512 value a few lines down must also be updated.
ENV DOTNET_SDK_VERSION 6.0.403

RUN dotnet_sdk_version=6.0.403 \
&& curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz \
&& dotnet_sha512='779b3e24a889dbb517e5ff5359dab45dd3296160e4cb5592e6e41ea15cbf87279f08405febf07517aa02351f953b603e59648550a096eefcb0a20fdaf03fadde' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& apt-get install -y --no-install-recommends \
curl \
git \
wget \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Install .NET SDK
RUN curl -fSL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
&& dotnet_sha512='2544f58c7409b1fd8fe2c7f600f6d2b6a1929318071f16789bd6abf6deea00bd496dd6ba7f2573bbf17c891c4f56a372a073e57712acfd3e80ea3eb1b3f9c3d0' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -ozxf dotnet.tar.gz -C /usr/share/dotnet \
&& tar -oxzf dotnet.tar.gz -C /usr/share/dotnet ./packs ./sdk ./sdk-manifests ./templates ./LICENSE.txt ./ThirdPartyNotices.txt \
&& rm dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
# Trigger first run experience by running arbitrary cmd
&& dotnet help

# Copy notebooks

COPY ./notebooks/ ${HOME}/notebooks/
FROM jupyter/base-notebook:ubuntu-22.04

# Copy package sources
ENV \
DOTNET_RUNNING_IN_DOCKER=true \
ASPNETCORE_URLS= \
# Do not generate certificate
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USER_POLLING_FILE_WATCHER=true \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip \
# `dotnet-interactive` expects some cultural-specific data, which entails installing `libicu`
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true \
# Opt out of telemetry until after we install jupyter when building the image, this prevents caching of machine id
DOTNET_CLI_TELEMETRY_OPTOUT=true

COPY ./nugetprops.config ${HOME}/nuget.config
# Copy Notebooks
COPY notebooks ${HOME}/notebooks

RUN chown -R ${NB_UID} ${HOME}
USER ${USER}
# Copy package sources
COPY nugetprops.config ${HOME}/nuget.config

#Install nteract
RUN pip install nteract_on_jupyter
USER root
COPY --from=dotnet-cli ["/usr/share/dotnet", "/usr/share/dotnet"]
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

# Install lastest build from master branch of Microsoft.DotNet.Interactive
RUN dotnet tool install -g Microsoft.dotnet-interactive --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"
# RUN dotnet tool install -g Microsoft.dotnet-interactive --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"

#latest stable from nuget.org
#RUN dotnet tool install -g Microsoft.dotnet-interactive --add-source "https://api.nuget.org/v3/index.json"
# Latest stable for net7.0 from nuget.org
RUN dotnet tool install -g Microsoft.dotnet-interactive --version 1.0.446104

ENV PATH="${PATH}:${HOME}/.dotnet/tools"
RUN echo "$PATH"

# Install kernel specs
RUN dotnet interactive jupyter install

# Enable telemetry once we install jupyter for the image
ENV DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT=false
ENV DOTNET_CLI_TELEMETRY_OPTOUT=false

# Set root to notebooks
WORKDIR ${HOME}/notebooks/
WORKDIR ${HOME}/notebooks/