This repository was archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Microsoft Container Regristry image for hosting Notebooks on Bind…
…er (#152)
- Loading branch information
1 parent
3c757f2
commit 34c39b6
Showing
3 changed files
with
32 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,31 @@ | ||
# The same image used by mybinder.org | ||
FROM python:3.7-slim | ||
# We use the iqsharp-base image, as that includes | ||
# the .NET Core SDK, IQ#, and Jupyter Notebook already | ||
# installed for us. | ||
FROM mcr.microsoft.com/quantum/iqsharp-base:0.8.1907.1701 | ||
|
||
# install qsharp and the notebook packages | ||
RUN pip install --no-cache --upgrade pip && \ | ||
pip install --no-cache notebook qsharp==0.8.1907.1701 | ||
|
||
# pre-requisites for .NET SDK | ||
RUN apt-get update && apt-get -y install wget && \ | ||
apt-get update && apt-get -y install pgp && \ | ||
apt-get update && apt-get -y install libgomp1 && \ | ||
# add vim for editing local files: | ||
apt-get update && apt-get -y install vim | ||
|
||
# install .NET SDK 2.2 | ||
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg && \ | ||
mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ && \ | ||
wget -q https://packages.microsoft.com/config/debian/9/prod.list && \ | ||
mv prod.list /etc/apt/sources.list.d/microsoft-prod.list && \ | ||
chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \ | ||
chown root:root /etc/apt/sources.list.d/microsoft-prod.list && \ | ||
apt-get -y install apt-transport-https && \ | ||
apt-get -y update && \ | ||
apt-get -y install dotnet-sdk-2.2 | ||
|
||
# create user with a home directory | ||
# Required for mybinder.org | ||
ARG NB_USER=jovyan | ||
ARG NB_UID=1000 | ||
ENV USER=${NB_USER} \ | ||
HOME=/home/${NB_USER} | ||
|
||
RUN adduser --disabled-password \ | ||
--gecos "Default user" \ | ||
--uid ${NB_UID} \ | ||
${NB_USER} | ||
WORKDIR ${HOME} | ||
USER ${USER} | ||
|
||
# Make sure .net tools is in the path | ||
ENV PATH=$PATH:${HOME}/dotnet:${HOME}/.dotnet/tools \ | ||
DOTNET_ROOT=${HOME}/dotnet \ | ||
IQSHARP_HOSTING_ENV=KATAS_DOCKERFILE | ||
|
||
# install IQSharp | ||
RUN dotnet tool install -g Microsoft.Quantum.IQSharp --version 0.8.1907.1701 | ||
RUN dotnet iqsharp install --user --path-to-tool="$(which dotnet-iqsharp)" | ||
# Add metadata indicating that this image is used for the katas. | ||
ENV IQSHARP_HOSTING_ENV=KATAS_DOCKERFILE | ||
|
||
# Make sure the contents of our repo are in ${HOME} | ||
# Required for mybinder.org | ||
COPY . ${HOME} | ||
USER root | ||
RUN chown -R ${NB_UID} ${HOME} | ||
USER ${NB_USER} | ||
RUN chown -R ${USER} ${HOME} && \ | ||
chmod +x ${HOME}/scripts/*.sh | ||
USER ${USER} | ||
|
||
# Pre-exec notebooks to improve first-use start time | ||
RUN dotnet build BasicGates | ||
RUN jupyter nbconvert BasicGates/BasicGates.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build CHSHGame | ||
RUN jupyter nbconvert CHSHGame/CHSHGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build DeutschJozsaAlgorithm | ||
RUN jupyter nbconvert DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build GHZGame | ||
RUN jupyter nbconvert GHZGame/GHZGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build GroversAlgorithm | ||
RUN jupyter nbconvert GroversAlgorithm/GroversAlgorithm.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build JointMeasurements | ||
RUN jupyter nbconvert JointMeasurements/JointMeasurements.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build MagicSquareGame | ||
RUN jupyter nbconvert MagicSquareGame/MagicSquareGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build Measurements | ||
RUN jupyter nbconvert Measurements/Measurements.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build QEC_BitFlipCode | ||
RUN jupyter nbconvert QEC_BitFlipCode/QEC_BitFlipCode.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build SolveSATWithGrover | ||
RUN jupyter nbconvert SolveSATWithGrover/SolveSATWithGrover.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build SuperdenseCoding | ||
RUN jupyter nbconvert SuperdenseCoding/SuperdenseCoding.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build Superposition | ||
RUN jupyter nbconvert Superposition/Superposition.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build Teleportation | ||
RUN jupyter nbconvert Teleportation/Teleportation.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN dotnet build tutorials/DeutschJozsaAlgorithm | ||
RUN jupyter nbconvert tutorials/DeutschJozsaAlgorithm/DeutschJozsaAlgorithmTutorial.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 | ||
|
||
RUN ${HOME}/scripts/prebuild-kata.sh BasicGates | ||
RUN ${HOME}/scripts/prebuild-kata.sh CHSHGame | ||
RUN ${HOME}/scripts/prebuild-kata.sh DeutschJozsaAlgorithm | ||
RUN ${HOME}/scripts/prebuild-kata.sh GHZGame | ||
RUN ${HOME}/scripts/prebuild-kata.sh GroversAlgorithm | ||
RUN ${HOME}/scripts/prebuild-kata.sh JointMeasurements | ||
RUN ${HOME}/scripts/prebuild-kata.sh MagicSquareGame | ||
RUN ${HOME}/scripts/prebuild-kata.sh Measurements | ||
RUN ${HOME}/scripts/prebuild-kata.sh QEC_BitFlipCode | ||
RUN ${HOME}/scripts/prebuild-kata.sh SolveSATWithGrover | ||
RUN ${HOME}/scripts/prebuild-kata.sh SuperdenseCoding | ||
RUN ${HOME}/scripts/prebuild-kata.sh Superposition | ||
RUN ${HOME}/scripts/prebuild-kata.sh Teleportation | ||
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/DeutschJozsaAlgorithm DeutschJozsaAlgorithmTutorial.ipynb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# prebuild-kata.sh <kata-folder> <kata-notebook> | ||
KATA_FOLDER=$1 | ||
KATA_NOTEBOOK=${2:-$1.ipynb} | ||
|
||
echo "Prebuilding: $KATA_NOTEBOOK in $KATA_FOLDER kata..." | ||
|
||
dotnet build $KATA_FOLDER | ||
jupyter nbconvert $KATA_FOLDER/$KATA_NOTEBOOK --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120 |