-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathDockerfile
More file actions
90 lines (77 loc) · 3.43 KB
/
Dockerfile
File metadata and controls
90 lines (77 loc) · 3.43 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# Dockerfile for OpEn/opengen
# Dockerfile version: 0.7.0
# Bundled Python package: opengen v0.10.0
# Bundled Rust notebook dependency: optimization_engine v0.11.0
# JupyterLab kernels: Python and Rust (Evcxr)
#
# Copyright (c) 2017 Pantelis Sopasakis and Emil Fresk
#
#
#
# -------- Run Instructions ----------------------------------------------------
# Run the docker image and start a terminal to access it by running:
#
# $ docker run -p 127.0.0.1:8888:8888 -it alphaville/open
#
# You will be able to access JupyterLab at http://localhost:8888/lab
# using Jupyter's default token authentication. To set a password, read the
# documentation.
#
#
FROM python:3.12-slim-bookworm
ARG OPENGEN_VERSION=0.10.0
ARG OPTIMIZATION_ENGINE_CRATE_VERSION=0.11.0
ARG EVCXR_JUPYTER_VERSION=0.21.1
# Labels for the docker image
LABEL maintainer="Pantelis Sopasakis <p.sopasakis@gmail.com>" \
license="MIT license" \
description="JupyterLab for Optimization Engine (OpEn) with Python and Rust kernels"
WORKDIR /open
# Example notebook content bundled with the image
COPY notebooks/ /open/notebooks/
ENV VIRTUAL_ENV=/venv
ENV PATH="${VIRTUAL_ENV}/bin:/root/.cargo/bin:${PATH}"
# These commands are groupped into a separate RUN to faciliate
# caching; it is unlikely that any of the following will change
# in future versions of this docker image
RUN apt-get update -y \
&& apt-get -y --no-install-recommends install \
build-essential \
ca-certificates \
curl \
&& curl https://sh.rustup.rs -sSf | bash -s -- -y --profile minimal \
&& rustup component add rust-src \
&& cargo install --locked "evcxr_jupyter@${EVCXR_JUPYTER_VERSION}" \
&& NOTEBOOK_BOOTSTRAP_DIR="$(mktemp -d)" \
&& mkdir -p "${NOTEBOOK_BOOTSTRAP_DIR}/src" \
&& printf '[package]\nname = "open-rust-notebook-bootstrap"\nversion = "0.1.0"\nedition = "2021"\n\n[dependencies]\noptimization_engine = "=%s"\n' "${OPTIMIZATION_ENGINE_CRATE_VERSION}" > "${NOTEBOOK_BOOTSTRAP_DIR}/Cargo.toml" \
&& printf 'fn main() {}\n' > "${NOTEBOOK_BOOTSTRAP_DIR}/src/main.rs" \
&& cargo generate-lockfile --manifest-path "${NOTEBOOK_BOOTSTRAP_DIR}/Cargo.toml" \
&& cargo fetch --locked --manifest-path "${NOTEBOOK_BOOTSTRAP_DIR}/Cargo.toml" \
&& rm -rf "${NOTEBOOK_BOOTSTRAP_DIR}" \
&& python -m pip install --no-cache-dir --upgrade "pip>=26.0.1" \
&& python -m venv "${VIRTUAL_ENV}" \
&& "${VIRTUAL_ENV}/bin/python" -m pip install --no-cache-dir --upgrade "pip>=26.0.1" wheel \
&& "${VIRTUAL_ENV}/bin/python" -m pip install --no-cache-dir "opengen==${OPENGEN_VERSION}" "jupyterlab<5" "matplotlib<4" \
&& JUPYTER_PATH="${VIRTUAL_ENV}/share/jupyter" evcxr_jupyter --install \
&& "${VIRTUAL_ENV}/bin/python" -m pip uninstall -y py \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source ${VIRTUAL_ENV}/bin/activate" >> /root/.bashrc
VOLUME /open
EXPOSE 8888
# Run the following command every time this docker image
# is executed
COPY start_jupyter_notebook.sh /usr/local/bin/start_jupyter_notebook.sh
RUN ["chmod", "+x", "/usr/local/bin/start_jupyter_notebook.sh"]
CMD ["/usr/local/bin/start_jupyter_notebook.sh"]
# -------- Build Instructions --------------------------------------------------
# Build the docker image by running (for DEVELOPERS only):
#
# $ docker image build -t alphaville/open:0.7.0 .
#
# from within the docker directory of this project.
#
#
# ------------------------------------------------------------------------------