From a6a0aa0fe2cdd342c14f7091c38cdd962c1b0981 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Sat, 9 Jan 2021 04:58:41 -0500 Subject: [PATCH] use Docker Compose for the development environment Simplifies the building of the image and the starting of the container. --- docker-compose.yml | 11 +++++++ docs/contributing/dev-setup.rst | 52 ++++++++++++++------------------- 2 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..ace1002c6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.9" +services: + hub: + build: ./integration-tests + privileged: true + volumes: + - type: bind + source: . + target: /srv/src + ports: + - "12000:80" diff --git a/docs/contributing/dev-setup.rst b/docs/contributing/dev-setup.rst index 40997a747..1e8f6ca7a 100644 --- a/docs/contributing/dev-setup.rst +++ b/docs/contributing/dev-setup.rst @@ -10,46 +10,27 @@ The easiest & safest way to develop & test TLJH is with `Docker `_. #. Clone the `git repo `_ (or your fork of it). -#. Build a docker image that has a functional systemd in it. +#. Build the Docker image and start the container. .. code-block:: bash - docker build -t tljh-systemd . -f integration-tests/Dockerfile + docker-compose up --build -#. 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 bootstrapper from inside the container (see step above): +#. From another terminal, run the bootstrapper: 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:: console + .. code-block:: bash - python3 /srv/src/bootstrap/bootstrap.py --admin admin + docker-compose exec hub python3 /srv/src/bootstrap/bootstrap.py --admin admin Or, if you would like to setup the admin's password during install, you can use this command (replace "admin" with the desired admin username and "password" with the desired admin password): - .. code-block:: console + .. code-block:: bash - python3 /srv/src/bootstrap/bootstrap.py --admin admin:password + docker-compose exec hub python3 /srv/src/bootstrap/bootstrap.py --admin admin:password The primary hub environment will also be in your PATH already for convenience. @@ -61,15 +42,26 @@ The easiest & safest way to develop & test TLJH is with `Docker