-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
DockerfileJupyter
62 lines (49 loc) · 3.14 KB
/
DockerfileJupyter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# LEAN Jupyter Docker Container 20190428
#
# Use base system for cleaning up wayward processes
ARG LEAN_TAG=latest
FROM quantconnect/lean:$LEAN_TAG
MAINTAINER QuantConnect <[email protected]>
# Install Tini
RUN if [ "$(uname -m)" = "aarch64" ]; then \
tini_binary="tini-arm64"; \
tini_sha256="07952557df20bfd2a95f9bef198b445e006171969499a1d361bd9e6f8e5e0e81"; \
else \
tini_binary="tini-amd64"; \
tini_sha256="93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c"; \
fi && \
wget --quiet -O tini "https://github.com/krallin/tini/releases/download/v0.19.0/${tini_binary}" && \
echo "${tini_sha256} *tini" | sha256sum -c - && \
mv tini /usr/local/bin/tini && \
chmod +x /usr/local/bin/tini
# Install clr-loader for PythonNet
RUN pip install --no-cache-dir clr-loader==0.1.6
# Install .NET Interactive to support C# in Jupyter notebooks
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install -g --no-cache --version 1.0.340501 --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive && \
dotnet interactive jupyter install
# Setting some environment variables
ENV WORK /Lean/Launcher/bin/Debug/
ENV PYTHONPATH=${WORK}:${PYTHONPATH}
# Link Python startup file to profile
RUN mkdir -p /root/.ipython/profile_default/startup/ && \
ln -s /Lean/Launcher/bin/Debug/start.py /root/.ipython/profile_default/startup/start.py
# conda libc is old and causes issues in research we want to use the hosts version which is updated
RUN mkdir -p /opt/miniconda3/lib/ && ln -vsf /lib/x86_64-linux-gnu/libstdc++.so.6 /opt/miniconda3/lib/libstdc++.so.6
RUN find ${WORK} -type f -not -name '*.py*' -not -name '*.xml' -not -name '*.exe.config' -not -name '*.exe' -not -name '*.so' -not -name '*.dll' -not -name '*.ipynb' -not -name '*.csx' -not -name 'QuantConnect.Lean.Launcher.runtimeconfig.json' -not -name 'decimal.py' -delete
# Create initialize script
RUN echo "if [ ! -d \"${WORK}Notebooks\" ]; then mkdir ${WORK}Notebooks; fi && \
if [ ! -f \"${WORK}Notebooks/config.json\" ]; then echo '{ \"data-folder\": \"/home/Data/\", \
\"composer-dll-directory\": \"$WORK\", \"algorithm-language\": \"Python\", \
\"messaging-handler\": \"QuantConnect.Messaging.Messaging\", \"job-queue-handler\": \"QuantConnect.Queues.JobQueue\", \
\"api-handler\": \"QuantConnect.Api.Api\" }' > ${WORK}Notebooks/config.json; fi && \
echo \"Starting JupyterLab, access in your browser at localhost:8888\" && \
jupyter lab --ip='0.0.0.0' --port=8888 --no-browser --allow-root --notebook-dir=\"Notebooks\" --LabApp.token='' " \
> start.sh
RUN echo "{\"argv\":[\"dotnet\",\"interactive\",\"jupyter\",\"--default-kernel\",\"csharp\",\"{connection_file}\",\"--http-port-range\",\"1000-3000\"],\"display_name\":\"Foundation-C#-Default\",\"language\":\"C#\",\"metadata\":{\"vscode\":{\"extension_id\":\"ms-dotnettools.dotnet-interactive-vscode\",\"kernel_id\":\"dotnet-interactive\"}}}" > /root/.local/share/jupyter/kernels/.net-csharp/kernel.json
RUN chmod -R 777 ${WORK}
EXPOSE 8888
WORKDIR $WORK
ENTRYPOINT [ "/usr/local/bin/tini", "--" ]
CMD ./start.sh