| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -523,11 +523,15 @@ ADD patches/sitecustomize.py /root/.local/lib/python3.6/site-packages/sitecustom | |||
| 523 | 523 | # Set backend for matplotlib | |
| 524 | 524 | ENV MPLBACKEND "agg" | |
| 525 | 525 | ||
| 526 | - # Set up pip to enable pip install. | ||
| 527 | - ADD patches/kaggle_bashrc /root | ||
| 528 | - # Patch the system-wide bashrc file for non-root users. | ||
| 529 | - RUN cat /root/kaggle_bashrc >> /etc/bash.bashrc | ||
| 530 | - RUN rm /root/kaggle_bashrc | ||
| 526 | + # Set up an initialization script to be executed before any other commands initiated by the user. | ||
| 527 | + ADD patches/entrypoint.sh /root/entrypoint.sh | ||
| 528 | + RUN chmod +x /root/entrypoint.sh | ||
| 529 | + # NOTE: ENTRYPOINT set by "FROM <image>" should preceed the our own custom entrypoint. | ||
| 530 | + # Currently tini is set as ENTRYPOINT for the base image, and it can be combined with our entrypoint (https://github.com/krallin/tini). | ||
| 531 | + # ENTRYPOINT gets executed by "docker run <image> <command>" and it runs <command> at the end of its execution. | ||
| 532 | + # Make sure tini exists. | ||
| 533 | + RUN /usr/bin/tini -h > /dev/null | ||
| 534 | + ENTRYPOINT ["/usr/bin/tini", "--", "/root/entrypoint.sh"] | ||
| 531 | 535 | ||
| 532 | 536 | # Finally, apply any locally defined patches. | |
| 533 | 537 | RUN /bin/bash -c \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,8 +18,14 @@ FROM gcr.io/kaggle-images/python:latest | |||
| 18 | 18 | ||
| 19 | 19 | RUN pip install --upgrade git+https://github.com/Kaggle/learntools | |
| 20 | 20 | ||
| 21 | - # Set up pip to enable pip install. | ||
| 22 | - ADD patches/kaggle_bashrc /root | ||
| 23 | - # Patch the system-wide bashrc file for non-root users. | ||
| 24 | - RUN cat /root/kaggle_bashrc >> /etc/bash.bashrc | ||
| 25 | - RUN rm /root/kaggle_bashrc | ||
| 21 | + # TODO(dsjang): Remove these lines once the docker image build turns green since they are copied from Dockerfile | ||
| 22 | + # to apply on top of the last green. | ||
| 23 | + # Set up an initialization script to be executed before any other commands initiated by the user. | ||
| 24 | + ADD patches/entrypoint.sh /root/entrypoint.sh | ||
| 25 | + RUN chmod +x /root/entrypoint.sh | ||
| 26 | + # NOTE: ENTRYPOINT set by "FROM <image>" should preceed the our own custom entrypoint. | ||
| 27 | + # Currently tini is set as ENTRYPOINT for the base image, and it can be combined with our entrypoint (https://github.com/krallin/tini). | ||
| 28 | + # ENTRYPOINT gets executed by "docker run <image> <command>" and it runs <command> at the end of its execution. | ||
| 29 | + # Make sure tini exists. | ||
| 30 | + RUN /usr/bin/tini -h > /dev/null | ||
| 31 | + ENTRYPOINT ["/usr/bin/tini", "--", "/root/entrypoint.sh"] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,14 @@ | |||
| 1 | + #!/usr/bin/env bash | ||
| 2 | + | ||
| 3 | + # This shell script is executed as an entrypoint file for the Kernels docker image. | ||
| 4 | + # It sets up the execution environment before starting the Jypyter Notebook Server. | ||
| 5 | + # Refer to https://docs.docker.com/engine/reference/builder/#entrypoint for details. | ||
| 1 | 6 | ||
| 2 | - # Kaggle-specific .bashrc script to be appended to /etc/bash.bashrc to apply it | ||
| 3 | - # when any user session starts. | ||
| 4 | 7 | # This script sets up pip to enable a user to install and use python modules via | |
| 5 | 8 | # pip intall. $KAGGLE_WORKING_DIR should be available for it to work. | |
| 6 | - | ||
| 7 | 9 | if [[ ! -z "${KAGGLE_WORKING_DIR}" ]]; then | |
| 8 | 10 | PIP_INSTALL_PREFIX_DIR="${KAGGLE_WORKING_DIR}/pip" | |
| 11 | + PIP_INSTALLED_MODULE_DIR="${PIP_INSTALL_PREFIX_DIR}/pip_installed" | ||
| 9 | 12 | PIP_CONFIG_FILE_PATH="${KAGGLE_WORKING_DIR}/config/pip/pip.conf" | |
| 10 | 13 | ||
| 11 | 14 | # Create a directory for pip to install modules. | |
@@ -15,17 +18,27 @@ if [[ ! -z "${KAGGLE_WORKING_DIR}" ]]; then | |||
| 15 | 18 | # installation. Also, ignore-installed is set to true to prevent pip | |
| 16 | 19 | # from trying to remove existing modules from the read-only filesystem. | |
| 17 | 20 | mkdir -p `dirname ${PIP_CONFIG_FILE_PATH}` | |
| 18 | - echo "[install]\nprefix=${PIP_INSTALL_PREFIX_DIR}\nignore-installed=true" > ${PIP_CONFIG_FILE_PATH} | ||
| 21 | + echo -e "[install]\nprefix=${PIP_INSTALL_PREFIX_DIR}\nignore-installed=true" > ${PIP_CONFIG_FILE_PATH} | ||
| 19 | 22 | # Instruct pip to use this config file. | |
| 20 | 23 | export PIP_CONFIG_FILE=${PIP_CONFIG_FILE_PATH} | |
| 21 | 24 | ||
| 22 | 25 | # Set up PYTHONPATH correctly to include the user-installed library. | |
| 23 | 26 | # Note that the pip prefix directory overrides the system default to enable | |
| 24 | 27 | # a user to use his/her installed one. | |
| 25 | 28 | # TODO(dsjang): Currently "lib/python3.6/site-packages" is hard-coded | |
| 26 | - # throughout Dockerfile. Parameterize it to avoid a version mismatch. | ||
| 27 | - export PYTHONPATH=${PIP_INSTALL_PREFIX_DIR}/lib/python3.6/site-packages:${PYTHONPATH} | ||
| 29 | + # throughout Dockerfile. Parameterize it to avoid a version mismatch. | ||
| 30 | + # TODO(dsjang): This is a hack to sidestep a problem of Python ignoring modules | ||
| 31 | + # in .../site-packages other than the system-wide and user-specific site packages. | ||
| 32 | + mkdir -p "${PIP_INSTALL_PREFIX_DIR}/lib/python3.6/site-packages" | ||
| 33 | + ln -s "${PIP_INSTALL_PREFIX_DIR}/lib/python3.6/site-packages" ${PIP_INSTALLED_MODULE_DIR} | ||
| 34 | + export PYTHONPATH=${PIP_INSTALLED_MODULE_DIR}:${PYTHONPATH} | ||
| 35 | + | ||
| 36 | + # Create a symbolic link to site-packages. | ||
| 37 | + # can't override conda installed package. | ||
| 28 | 38 | ||
| 29 | 39 | # Include pip-installed binaries in PATH. | |
| 30 | 40 | export PATH=${PATH}:${PIP_INSTALL_PREFIX_DIR}/bin | |
| 31 | - fi | ||
| 41 | + fi | ||
| 42 | + | ||
| 43 | + # Execute the command provided from "docker run" in the current process. | ||
| 44 | + exec "$@" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments