diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bfebfbf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Systemd inside a Docker container, for CI only +FROM ubuntu:18.04 + +RUN apt-get update --yes + +RUN apt-get install --yes systemd curl git + +# Kill all the things we don't need +RUN find /etc/systemd/system \ + /lib/systemd/system \ + -path '*.wants/*' \ + -not -name '*journald*' \ + -not -name '*systemd-tmpfiles*' \ + -not -name '*systemd-user-sessions*' \ + -exec rm \{} \; + +RUN mkdir -p /etc/sudoers.d + +RUN systemctl set-default multi-user.target + +STOPSIGNAL SIGRTMIN+3 + +# Set up image to be useful out of the box for development & CI +ENV TLJH_INSTALL_PIP_FLAGS="--no-cache-dir -e" +ENV TLJH_INSTALL_PIP_SPEC=/srv/src +ENV PATH=/opt/tljh/hub/bin:${PATH} + +CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"] diff --git a/docs/contributing/dev-setup.rst b/docs/contributing/dev-setup.rst new file mode 100644 index 0000000..e33d847 --- /dev/null +++ b/docs/contributing/dev-setup.rst @@ -0,0 +1,65 @@ +.. _contributing_dev_setup: + +Setting up Development Environment +================================== + +The easiest & safest way to develop & test TLJH is with `Docker `_. + +#. Install Docker Community Edition by following the instructions on + `their website `_. + +#. Clone the git repo (or your fork of it). +#. Build a docker image that has a functional systemd in it. + + .. code-block:: bash + + sudo docker build -t tljh-systemd . + +#. Run a docker container with the image in the background, while bind mounting + your TLJH repository under ``/srv/src``. + + .. code-block:: bash + + docker run \ + --privileged \ + --detach \ + --name=tljh-dev \ + --publish 12000:80 \ + --mount type=bind,source=$(pwd),target=/srv/src \ + tljh-systemd + +#. Get a shell inside the running docker container. + + .. code-block:: bash + + docker exec -it tljh-dev /bin/bash + +#. Run the installer! The container image is already set up to default to a + ``dev`` install, so it'll install from your local repo rather than from github. + + .. code-block:: bash + + bash /srv/src/installer/install.bash + + The primary hub environment will also be in your PATH already for convenience. + +#. You should be able to access the JupyterHub from your browser now at + `http://localhost:1200 `_. Congratulations, you are + set up to develop TLJH! + +#. Make some changes to the repository. You can test easily depending on what + you changed. + + * If you changed the ``installer/install.bash`` script or any of its dependencies, + you can test it by running ``bash /srv/src/installer/install.bash``. + + * If you changed the ``tljh/installer.py`` code (or any of its dependencies), + you can test it by running ``python3 -m tljh.installer``. + + * If you changed ``tljh/jupyterhub_config.py``, ``tljh/configurer.py``, + ``/opt/tljh/config.yaml`` or any of their dependencies, you only need to + restart jupyterhub for them to take effect. ``systemctl restart jupyterhub`` + should do that. + +:ref:`troubleshoot_logs` has information on looking at various logs in the container +to debug issues you might have. diff --git a/docs/index.rst b/docs/index.rst index dd48462..417ddb9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -53,3 +53,14 @@ guides help you find what is broken & hopefully fix it. :titlesonly: troubleshooting/logs + +Contributing +============ + +Whatever you think your skillsets are, your contributions to TLJH are highly +appreciated. + +.. toctree:: + :titlesonly: + + contributing/dev-setup diff --git a/installer/install.bash b/installer/install.bash index 29a0c2e..c1017ed 100755 --- a/installer/install.bash +++ b/installer/install.bash @@ -13,7 +13,7 @@ function install_miniconda { URL="https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh" INSTALLER_PATH=/tmp/miniconda-installer.sh - wget $URL -O ${INSTALLER_PATH} + curl -o ${INSTALLER_PATH} ${URL} chmod +x ${INSTALLER_PATH} # Only MD5 checksums are available for miniconda