Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 34c39b6

Browse files
Chris GranadetcNickolas
authored andcommitted
Use Microsoft Container Regristry image for hosting Notebooks on Binder (#152)
1 parent 3c757f2 commit 34c39b6

File tree

3 files changed

+32
-91
lines changed

3 files changed

+32
-91
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# Set default behavior to automatically normalize line endings.
33
###############################################################################
44
* text=auto
5-
*.sh text eol=lf
5+
*.sh text -crlf eol=lf
66

Dockerfile

Lines changed: 23 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,31 @@
1-
# The same image used by mybinder.org
2-
FROM python:3.7-slim
1+
# We use the iqsharp-base image, as that includes
2+
# the .NET Core SDK, IQ#, and Jupyter Notebook already
3+
# installed for us.
4+
FROM mcr.microsoft.com/quantum/iqsharp-base:0.8.1907.1701
35

4-
# install qsharp and the notebook packages
5-
RUN pip install --no-cache --upgrade pip && \
6-
pip install --no-cache notebook qsharp==0.8.1907.1701
7-
8-
# pre-requisites for .NET SDK
9-
RUN apt-get update && apt-get -y install wget && \
10-
apt-get update && apt-get -y install pgp && \
11-
apt-get update && apt-get -y install libgomp1 && \
12-
# add vim for editing local files:
13-
apt-get update && apt-get -y install vim
14-
15-
# install .NET SDK 2.2
16-
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg && \
17-
mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ && \
18-
wget -q https://packages.microsoft.com/config/debian/9/prod.list && \
19-
mv prod.list /etc/apt/sources.list.d/microsoft-prod.list && \
20-
chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \
21-
chown root:root /etc/apt/sources.list.d/microsoft-prod.list && \
22-
apt-get -y install apt-transport-https && \
23-
apt-get -y update && \
24-
apt-get -y install dotnet-sdk-2.2
25-
26-
# create user with a home directory
27-
# Required for mybinder.org
28-
ARG NB_USER=jovyan
29-
ARG NB_UID=1000
30-
ENV USER=${NB_USER} \
31-
HOME=/home/${NB_USER}
32-
33-
RUN adduser --disabled-password \
34-
--gecos "Default user" \
35-
--uid ${NB_UID} \
36-
${NB_USER}
37-
WORKDIR ${HOME}
38-
USER ${USER}
39-
40-
# Make sure .net tools is in the path
41-
ENV PATH=$PATH:${HOME}/dotnet:${HOME}/.dotnet/tools \
42-
DOTNET_ROOT=${HOME}/dotnet \
43-
IQSHARP_HOSTING_ENV=KATAS_DOCKERFILE
44-
45-
# install IQSharp
46-
RUN dotnet tool install -g Microsoft.Quantum.IQSharp --version 0.8.1907.1701
47-
RUN dotnet iqsharp install --user --path-to-tool="$(which dotnet-iqsharp)"
6+
# Add metadata indicating that this image is used for the katas.
7+
ENV IQSHARP_HOSTING_ENV=KATAS_DOCKERFILE
488

499
# Make sure the contents of our repo are in ${HOME}
5010
# Required for mybinder.org
5111
COPY . ${HOME}
5212
USER root
53-
RUN chown -R ${NB_UID} ${HOME}
54-
USER ${NB_USER}
13+
RUN chown -R ${USER} ${HOME} && \
14+
chmod +x ${HOME}/scripts/*.sh
15+
USER ${USER}
5516

5617
# Pre-exec notebooks to improve first-use start time
57-
RUN dotnet build BasicGates
58-
RUN jupyter nbconvert BasicGates/BasicGates.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
59-
60-
RUN dotnet build CHSHGame
61-
RUN jupyter nbconvert CHSHGame/CHSHGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
62-
63-
RUN dotnet build DeutschJozsaAlgorithm
64-
RUN jupyter nbconvert DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
65-
66-
RUN dotnet build GHZGame
67-
RUN jupyter nbconvert GHZGame/GHZGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
68-
69-
RUN dotnet build GroversAlgorithm
70-
RUN jupyter nbconvert GroversAlgorithm/GroversAlgorithm.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
71-
72-
RUN dotnet build JointMeasurements
73-
RUN jupyter nbconvert JointMeasurements/JointMeasurements.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
74-
75-
RUN dotnet build MagicSquareGame
76-
RUN jupyter nbconvert MagicSquareGame/MagicSquareGame.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
77-
78-
RUN dotnet build Measurements
79-
RUN jupyter nbconvert Measurements/Measurements.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
80-
81-
RUN dotnet build QEC_BitFlipCode
82-
RUN jupyter nbconvert QEC_BitFlipCode/QEC_BitFlipCode.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
83-
84-
RUN dotnet build SolveSATWithGrover
85-
RUN jupyter nbconvert SolveSATWithGrover/SolveSATWithGrover.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
86-
87-
RUN dotnet build SuperdenseCoding
88-
RUN jupyter nbconvert SuperdenseCoding/SuperdenseCoding.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
89-
90-
RUN dotnet build Superposition
91-
RUN jupyter nbconvert Superposition/Superposition.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
92-
93-
RUN dotnet build Teleportation
94-
RUN jupyter nbconvert Teleportation/Teleportation.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
95-
96-
RUN dotnet build tutorials/DeutschJozsaAlgorithm
97-
RUN jupyter nbconvert tutorials/DeutschJozsaAlgorithm/DeutschJozsaAlgorithmTutorial.ipynb --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120
98-
18+
RUN ${HOME}/scripts/prebuild-kata.sh BasicGates
19+
RUN ${HOME}/scripts/prebuild-kata.sh CHSHGame
20+
RUN ${HOME}/scripts/prebuild-kata.sh DeutschJozsaAlgorithm
21+
RUN ${HOME}/scripts/prebuild-kata.sh GHZGame
22+
RUN ${HOME}/scripts/prebuild-kata.sh GroversAlgorithm
23+
RUN ${HOME}/scripts/prebuild-kata.sh JointMeasurements
24+
RUN ${HOME}/scripts/prebuild-kata.sh MagicSquareGame
25+
RUN ${HOME}/scripts/prebuild-kata.sh Measurements
26+
RUN ${HOME}/scripts/prebuild-kata.sh QEC_BitFlipCode
27+
RUN ${HOME}/scripts/prebuild-kata.sh SolveSATWithGrover
28+
RUN ${HOME}/scripts/prebuild-kata.sh SuperdenseCoding
29+
RUN ${HOME}/scripts/prebuild-kata.sh Superposition
30+
RUN ${HOME}/scripts/prebuild-kata.sh Teleportation
31+
RUN ${HOME}/scripts/prebuild-kata.sh tutorials/DeutschJozsaAlgorithm DeutschJozsaAlgorithmTutorial.ipynb

scripts/prebuild-kata.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# prebuild-kata.sh <kata-folder> <kata-notebook>
2+
KATA_FOLDER=$1
3+
KATA_NOTEBOOK=${2:-$1.ipynb}
4+
5+
echo "Prebuilding: $KATA_NOTEBOOK in $KATA_FOLDER kata..."
6+
7+
dotnet build $KATA_FOLDER
8+
jupyter nbconvert $KATA_FOLDER/$KATA_NOTEBOOK --execute --stdout --to markdown --allow-errors --ExecutePreprocessor.timeout=120

0 commit comments

Comments
 (0)