|
1 | | -# -------- Licence ------------------------------------------------------------- |
2 | | -# Dual license: MIT and Apache v2 |
| 1 | +# |
| 2 | +# Dockerfile for OpEn/opengen |
| 3 | +# Dockerfile version: 0.7.0 |
| 4 | +# Bundled Python package: opengen v0.10.0 |
| 5 | +# Bundled Rust notebook dependency: optimization_engine v0.11.0 |
| 6 | +# JupyterLab kernels: Python and Rust (Evcxr) |
3 | 7 | # |
4 | 8 | # Copyright (c) 2017 Pantelis Sopasakis and Emil Fresk |
5 | | -# ------------------------------------------------------------------------------ |
6 | | - |
7 | | - |
| 9 | +# |
| 10 | +# |
| 11 | +# |
8 | 12 | # -------- Run Instructions ---------------------------------------------------- |
9 | 13 | # Run the docker image and start a terminal to access it by running: |
10 | 14 | # |
11 | | -# $ docker run -p 8888:8888 -it alphaville/open |
| 15 | +# $ docker run -p 127.0.0.1:8888:8888 -it alphaville/open |
12 | 16 | # |
13 | | -# You will be able to access your Jupyter Notebook at http://localhost:8888/ |
14 | | -# without a password. To set a password, read the documentation. |
| 17 | +# You will be able to access JupyterLab at http://localhost:8888/lab |
| 18 | +# using Jupyter's default token authentication. To set a password, read the |
| 19 | +# documentation. |
15 | 20 | # |
16 | | -# ------------------------------------------------------------------------------ |
| 21 | +# |
| 22 | + |
| 23 | +FROM python:3.12-slim-bookworm |
17 | 24 |
|
18 | | -FROM debian:stable |
| 25 | +ARG OPENGEN_VERSION=0.10.0 |
| 26 | +ARG OPTIMIZATION_ENGINE_CRATE_VERSION=0.11.0 |
| 27 | +ARG EVCXR_JUPYTER_VERSION=0.21.1 |
19 | 28 |
|
20 | 29 | # Labels for the docker image |
21 | 30 | LABEL maintainer="Pantelis Sopasakis <p.sopasakis@gmail.com>" \ |
22 | 31 | license="MIT license" \ |
23 | | - description="Jupyter notebook for Optimization Engine (OpEn)" |
| 32 | + description="JupyterLab for Optimization Engine (OpEn) with Python and Rust kernels" |
24 | 33 |
|
25 | 34 | WORKDIR /open |
26 | | -VOLUME /open |
27 | 35 |
|
28 | | -# Example Python notebook |
29 | | -COPY example.ipynb /open/ |
| 36 | +# Example notebook content bundled with the image |
| 37 | +COPY notebooks/ /open/notebooks/ |
30 | 38 |
|
31 | | -ENV PATH="/root/.cargo/bin:${PATH}" |
| 39 | +ENV VIRTUAL_ENV=/venv |
| 40 | +ENV PATH="${VIRTUAL_ENV}/bin:/root/.cargo/bin:${PATH}" |
32 | 41 |
|
33 | 42 | # These commands are groupped into a separate RUN to faciliate |
34 | 43 | # caching; it is unlikely that any of the following will change |
35 | 44 | # in future versions of this docker image |
36 | 45 | RUN apt-get update -y \ |
37 | 46 | && apt-get -y --no-install-recommends install \ |
38 | 47 | build-essential \ |
| 48 | + ca-certificates \ |
39 | 49 | curl \ |
40 | | - jupyter-notebook \ |
41 | | - python3 \ |
42 | | - python3-pip \ |
43 | | - python3-setuptools \ |
44 | | - python3-venv \ |
45 | | - && curl https://sh.rustup.rs -sSf | bash -s -- -y \ |
46 | | - && cd /; python3 -m venv venv \ |
47 | | - && /bin/bash -c "source /venv/bin/activate && pip install wheel && pip install opengen && pip install jupyter" \ |
| 50 | + && curl https://sh.rustup.rs -sSf | bash -s -- -y --profile minimal \ |
| 51 | + && rustup component add rust-src \ |
| 52 | + && cargo install --locked "evcxr_jupyter@${EVCXR_JUPYTER_VERSION}" \ |
| 53 | + && NOTEBOOK_BOOTSTRAP_DIR="$(mktemp -d)" \ |
| 54 | + && mkdir -p "${NOTEBOOK_BOOTSTRAP_DIR}/src" \ |
| 55 | + && 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" \ |
| 56 | + && printf 'fn main() {}\n' > "${NOTEBOOK_BOOTSTRAP_DIR}/src/main.rs" \ |
| 57 | + && cargo generate-lockfile --manifest-path "${NOTEBOOK_BOOTSTRAP_DIR}/Cargo.toml" \ |
| 58 | + && cargo fetch --locked --manifest-path "${NOTEBOOK_BOOTSTRAP_DIR}/Cargo.toml" \ |
| 59 | + && rm -rf "${NOTEBOOK_BOOTSTRAP_DIR}" \ |
| 60 | + && python -m pip install --no-cache-dir --upgrade "pip>=26.0.1" \ |
| 61 | + && python -m venv "${VIRTUAL_ENV}" \ |
| 62 | + && "${VIRTUAL_ENV}/bin/python" -m pip install --no-cache-dir --upgrade "pip>=26.0.1" wheel \ |
| 63 | + && "${VIRTUAL_ENV}/bin/python" -m pip install --no-cache-dir "opengen==${OPENGEN_VERSION}" "jupyterlab<5" "matplotlib<4" \ |
| 64 | + && JUPYTER_PATH="${VIRTUAL_ENV}/share/jupyter" evcxr_jupyter --install \ |
| 65 | + && "${VIRTUAL_ENV}/bin/python" -m pip uninstall -y py \ |
48 | 66 | && apt-get clean \ |
49 | 67 | && rm -rf /var/lib/apt/lists/* \ |
50 | | - && echo "source /venv/bin/activate" >> /root/.bashrc |
| 68 | + && echo "source ${VIRTUAL_ENV}/bin/activate" >> /root/.bashrc |
| 69 | + |
| 70 | +VOLUME /open |
51 | 71 |
|
52 | 72 | EXPOSE 8888 |
53 | 73 |
|
54 | 74 | # Run the following command every time this docker image |
55 | 75 | # is executed |
56 | | -COPY start_jupyter_notebook.sh / |
57 | | -RUN ["chmod", "+x", "/start_jupyter_notebook.sh"] |
58 | | -CMD ["/bin/bash", "/start_jupyter_notebook.sh"] |
| 76 | +COPY start_jupyter_notebook.sh /usr/local/bin/start_jupyter_notebook.sh |
| 77 | +RUN ["chmod", "+x", "/usr/local/bin/start_jupyter_notebook.sh"] |
| 78 | +CMD ["/usr/local/bin/start_jupyter_notebook.sh"] |
59 | 79 |
|
60 | 80 |
|
61 | 81 |
|
62 | 82 | # -------- Build Instructions -------------------------------------------------- |
63 | 83 | # Build the docker image by running (for DEVELOPERS only): |
64 | 84 | # |
65 | | -# $ docker image build -t alphaville/open . |
| 85 | +# $ docker image build -t alphaville/open:0.7.0 . |
66 | 86 | # |
67 | | -# from within the base directory of this project. |
| 87 | +# from within the docker directory of this project. |
68 | 88 | # |
69 | 89 | # |
70 | 90 | # ------------------------------------------------------------------------------ |
0 commit comments