From e5f711e774e80189cedee8db0efb94f967750a48 Mon Sep 17 00:00:00 2001 From: Ryan Smith Date: Thu, 10 Oct 2024 22:12:18 +0100 Subject: [PATCH 1/7] Use service profiles to specify drunc-lite use case --- docker-compose.yml | 14 ++++++++++++++ drunc_docker_service_lite/Dockerfile | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 drunc_docker_service_lite/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 44bc8d8..efd7990 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,8 @@ services: - db:/usr/src/app/db drunc: build: ./drunc_docker_service/ + profiles: + - drunc command: - bash - -c @@ -23,5 +25,17 @@ services: drunc-process-manager --log-level debug file://./data/process-manager-no-kafka.json expose: - 10054 + drunc-lite: + build: ./drunc_docker_service_lite/ + profiles: + - drunc-lite + command: + - sh + - -c + - | + service ssh start && + drunc-process-manager --log-level debug file:///process-manager-no-kafka.json + expose: + - 10054 volumes: db: diff --git a/drunc_docker_service_lite/Dockerfile b/drunc_docker_service_lite/Dockerfile new file mode 100644 index 0000000..98c9867 --- /dev/null +++ b/drunc_docker_service_lite/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.11-slim-bookworm + +RUN apt-get update \ + && apt-get -y install --no-install-recommends git ssh openssh-server \ + && rm -fr /var/lib/apt/lists/* + +COPY requirements.txt / +RUN pip install --no-cache-dir -r /requirements.txt + +COPY process-manager-no-kafka.json / + +EXPOSE 22 +RUN mkdir -p /root/.ssh && \ + ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" && \ + cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys + +RUN echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config && \ + echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \ + echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config + +RUN mkdir -p /usr/src/app From 8936955b74e0d80ae05d65ace71b79020e762264 Mon Sep 17 00:00:00 2001 From: Ryan Smith Date: Mon, 14 Oct 2024 11:04:15 +0100 Subject: [PATCH 2/7] Recreate requirements.txt and amend paths --- .dockerignore | 2 ++ docker-compose.yml | 4 +++- drunc_docker_service_lite/Dockerfile | 4 ++-- drunc_docker_service_lite/requirements.txt | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 drunc_docker_service_lite/requirements.txt diff --git a/.dockerignore b/.dockerignore index 3694f75..77001b9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,3 +6,5 @@ !dune_processes !db db/* +!drunc_docker_service_lite/requirements.txt +!drunc_docker_service/process-manager-no-kafka.json diff --git a/docker-compose.yml b/docker-compose.yml index efd7990..3960a3e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,9 @@ services: expose: - 10054 drunc-lite: - build: ./drunc_docker_service_lite/ + build: + context: . + dockerfile: ./drunc_docker_service_lite/Dockerfile profiles: - drunc-lite command: diff --git a/drunc_docker_service_lite/Dockerfile b/drunc_docker_service_lite/Dockerfile index 98c9867..6199834 100644 --- a/drunc_docker_service_lite/Dockerfile +++ b/drunc_docker_service_lite/Dockerfile @@ -4,10 +4,10 @@ RUN apt-get update \ && apt-get -y install --no-install-recommends git ssh openssh-server \ && rm -fr /var/lib/apt/lists/* -COPY requirements.txt / +COPY drunc_docker_service_lite/requirements.txt / RUN pip install --no-cache-dir -r /requirements.txt -COPY process-manager-no-kafka.json / +COPY drunc_docker_service/process-manager-no-kafka.json / EXPOSE 22 RUN mkdir -p /root/.ssh && \ diff --git a/drunc_docker_service_lite/requirements.txt b/drunc_docker_service_lite/requirements.txt new file mode 100644 index 0000000..db4c93e --- /dev/null +++ b/drunc_docker_service_lite/requirements.txt @@ -0,0 +1,2 @@ +git+https://github.com/DUNE-DAQ/drunc.git@v0.10.4 +git+https://github.com/DUNE-DAQ/druncschema.git@v0.8.1 From 17edca7dea95e24e47e0b4a77da11bc4b2d5e956 Mon Sep 17 00:00:00 2001 From: Ryan Smith Date: Mon, 14 Oct 2024 12:06:45 +0100 Subject: [PATCH 3/7] Add line to pre-commit workflow to fix failure. --- .github/workflows/pre-commit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 2750e6a..5510a82 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,6 +10,7 @@ jobs: runs-on: [ubuntu-latest] steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1 - uses: pre-commit-ci/lite-action@v1.0.3 if: always() From f133036e83dc5dc1790daed68aff02149ad7c830 Mon Sep 17 00:00:00 2001 From: Christopher Cave-Ayland Date: Thu, 17 Oct 2024 10:46:43 +0100 Subject: [PATCH 4/7] Get profiles working --- .dockerignore | 2 +- docker-compose.yml | 3 +-- drunc_docker_service/Dockerfile | 2 +- drunc_docker_service_lite/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3db696b..ddc5bff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,4 @@ !db db/* !drunc_docker_service_lite/requirements.txt -!drunc_docker_service/process-manager-no-kafka.json +!drunc_docker_service/process-manager-kafka.json diff --git a/docker-compose.yml b/docker-compose.yml index 62080f2..62574a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,6 @@ services: - db:/usr/src/app/db environment: - PROCESS_MANAGER_URL=drunc:10054 - depends_on: - - drunc drunc: build: ./drunc_docker_service/ profiles: @@ -36,6 +34,7 @@ services: build: context: . dockerfile: ./drunc_docker_service_lite/Dockerfile + container_name: drunc profiles: - drunc-lite command: diff --git a/drunc_docker_service/Dockerfile b/drunc_docker_service/Dockerfile index 7931bc2..5ad56af 100644 --- a/drunc_docker_service/Dockerfile +++ b/drunc_docker_service/Dockerfile @@ -18,7 +18,7 @@ RUN source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh && \ pip install git+https://github.com/DUNE-DAQ/drunc.git@v0.10.2 WORKDIR /basedir/fddaq-v5.1.0-a9/ -COPY process-manager-no-kafka.json process-manager-kafka.json data/ +COPY process-manager-kafka.json / RUN mkdir -p /root/.ssh && \ ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" && \ diff --git a/drunc_docker_service_lite/Dockerfile b/drunc_docker_service_lite/Dockerfile index 8a5cd1f..a9c0d53 100644 --- a/drunc_docker_service_lite/Dockerfile +++ b/drunc_docker_service_lite/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update \ COPY drunc_docker_service_lite/requirements.txt / RUN pip install --no-cache-dir -r /requirements.txt -COPY drunc_docker_service/process-manager-no-kafka.json drunc_docker_service/process-manager-kafka.json / +COPY drunc_docker_service/process-manager-kafka.json / EXPOSE 22 RUN mkdir -p /root/.ssh && \ From a53b48c88fd609b09358a2f5c51d4cba24a5960b Mon Sep 17 00:00:00 2001 From: Christopher Cave-Ayland Date: Thu, 17 Oct 2024 12:22:19 +0100 Subject: [PATCH 5/7] Refactor docker images --- docker-compose.yml | 4 ++-- drunc_docker_service/Dockerfile | 15 ++++++------- drunc_docker_service/Dockerfile_lite | 16 ++++++++++++++ .../lite_requirements.txt | 0 drunc_docker_service/ssh-setup.sh | 16 ++++++++++++++ drunc_docker_service_lite/Dockerfile | 21 ------------------- 6 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 drunc_docker_service/Dockerfile_lite rename drunc_docker_service_lite/requirements.txt => drunc_docker_service/lite_requirements.txt (100%) create mode 100644 drunc_docker_service/ssh-setup.sh delete mode 100644 drunc_docker_service_lite/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 62574a3..3f7c66d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,8 +32,8 @@ services: condition: service_healthy drunc-lite: build: - context: . - dockerfile: ./drunc_docker_service_lite/Dockerfile + context: ./drunc_docker_service/ + dockerfile: ./Dockerfile_lite container_name: drunc profiles: - drunc-lite diff --git a/drunc_docker_service/Dockerfile b/drunc_docker_service/Dockerfile index 5ad56af..5a14597 100644 --- a/drunc_docker_service/Dockerfile +++ b/drunc_docker_service/Dockerfile @@ -7,7 +7,9 @@ SHELL ["/bin/bash", "-c"] WORKDIR /basedir -# for frozen release +# setup for the the dune development environment that provides the full set of +# dependencies required for booting of the controller test session +# See https://github.com/DUNE-DAQ/drunc/wiki/Setup-drunc-with-DUNE-DAQ for explanation RUN source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh && \ setup_dbt latest_v5 && \ dbt-create fddaq-v5.1.0-a9 fddaq-v5.1.0-a9 && \ @@ -20,14 +22,9 @@ WORKDIR /basedir/fddaq-v5.1.0-a9/ COPY process-manager-kafka.json / -RUN mkdir -p /root/.ssh && \ - ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" && \ - cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys - -RUN echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config && \ - echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \ - echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \ - ssh-keygen -A +# setup ssh server config and keys +ADD ssh-setup.sh / +RUN bash /ssh-setup.sh RUN mkdir -p /usr/src/app ENTRYPOINT [] diff --git a/drunc_docker_service/Dockerfile_lite b/drunc_docker_service/Dockerfile_lite new file mode 100644 index 0000000..0d479e0 --- /dev/null +++ b/drunc_docker_service/Dockerfile_lite @@ -0,0 +1,16 @@ +FROM python:3.11-slim-bookworm + +RUN apt-get update \ + && apt-get -y install --no-install-recommends git ssh openssh-server \ + && rm -fr /var/lib/apt/lists/* + +COPY lite_requirements.txt /requirements.txt +RUN pip install --no-cache-dir -r /requirements.txt + +COPY process-manager-kafka.json / + +# setup ssh server config and keys +ADD ssh-setup.sh / +RUN bash /ssh-setup.sh + +RUN mkdir -p /usr/src/app diff --git a/drunc_docker_service_lite/requirements.txt b/drunc_docker_service/lite_requirements.txt similarity index 100% rename from drunc_docker_service_lite/requirements.txt rename to drunc_docker_service/lite_requirements.txt diff --git a/drunc_docker_service/ssh-setup.sh b/drunc_docker_service/ssh-setup.sh new file mode 100644 index 0000000..d8d5c78 --- /dev/null +++ b/drunc_docker_service/ssh-setup.sh @@ -0,0 +1,16 @@ +# Setup the ssh server configuration and keys + +set -e + +# create an ssh key for the root user +mkdir -p /root/.ssh +ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" + +# allow the key to be used to authenticate ssh connections +cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys + +# configure the ssh server to allow the root user to login only with an ssh key +echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config + +# generate a unique host key +ssh-keygen -A diff --git a/drunc_docker_service_lite/Dockerfile b/drunc_docker_service_lite/Dockerfile deleted file mode 100644 index a9c0d53..0000000 --- a/drunc_docker_service_lite/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM python:3.11-slim-bookworm - -RUN apt-get update \ - && apt-get -y install --no-install-recommends git ssh openssh-server \ - && rm -fr /var/lib/apt/lists/* - -COPY drunc_docker_service_lite/requirements.txt / -RUN pip install --no-cache-dir -r /requirements.txt - -COPY drunc_docker_service/process-manager-kafka.json / - -EXPOSE 22 -RUN mkdir -p /root/.ssh && \ - ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" && \ - cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys - -RUN echo "PermitRootLogin without-password" >> /etc/ssh/sshd_config && \ - echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \ - echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config - -RUN mkdir -p /usr/src/app From 8ecf86a7ecf310bd123d5ed886ebad0cb3b732bb Mon Sep 17 00:00:00 2001 From: Christopher Cave-Ayland Date: Thu, 17 Oct 2024 12:54:52 +0100 Subject: [PATCH 6/7] Add entry point and scripts to make drunc image easier to work with --- README.md | 4 ++-- docker-compose.yml | 1 - drunc_docker_service/Dockerfile | 7 ++++++- drunc_docker_service/boot_test_session.sh | 7 +++++++ drunc_docker_service/entrypoint.sh | 6 ++++++ 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 drunc_docker_service/boot_test_session.sh create mode 100644 drunc_docker_service/entrypoint.sh diff --git a/README.md b/README.md index 152dbc4..24f406e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ docker compose exec app python scripts/talk_to_process_manager.py To boot a more realistic test session: ```bash -docker compose exec drunc bash -c "source env.sh && drunc-process-manager-shell grpc://localhost:10054 boot test/config/test-session.data.xml test-session" +docker compose exec drunc /boot_test_session.sh ``` _Note that the above consumes several Gb of memory._ @@ -48,7 +48,7 @@ _Note that the above consumes several Gb of memory._ Once booted you can interact with the root controller via: ```bash -docker compose exec drunc bash -c "source env.sh && drunc-controller-shell grpc://localhost:3333" +docker compose exec drunc /entrypoint.sh drunc-controller-shell grpc://localhost:3333 ``` For details of working with the controller see the [drunc wiki]. diff --git a/docker-compose.yml b/docker-compose.yml index 3f7c66d..f487ad1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,6 @@ services: - -c - | /usr/sbin/sshd && - source env.sh && drunc-process-manager --log-level debug file:///process-manager-kafka.json expose: - 10054 diff --git a/drunc_docker_service/Dockerfile b/drunc_docker_service/Dockerfile index 5a14597..73f84b9 100644 --- a/drunc_docker_service/Dockerfile +++ b/drunc_docker_service/Dockerfile @@ -27,6 +27,11 @@ ADD ssh-setup.sh / RUN bash /ssh-setup.sh RUN mkdir -p /usr/src/app -ENTRYPOINT [] +ADD entrypoint.sh / +RUN chmod a+x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] ADD wibeth_output_all_zeros.bin /cvmfs/dunedaq.opensciencegrid.org/assets/files/d/d/1/wibeth_output_all_zeros.bin + +ADD boot_test_session.sh / +RUN chmod a+x /boot_test_session.sh diff --git a/drunc_docker_service/boot_test_session.sh b/drunc_docker_service/boot_test_session.sh new file mode 100644 index 0000000..64cb95e --- /dev/null +++ b/drunc_docker_service/boot_test_session.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# setup dunedaq environment +. /basedir/fddaq-v5.1.0-a9/env.sh + +# boot full test session +drunc-process-manager-shell grpc://localhost:10054 boot test/config/test-session.data.xml test-session diff --git a/drunc_docker_service/entrypoint.sh b/drunc_docker_service/entrypoint.sh new file mode 100644 index 0000000..be86b4f --- /dev/null +++ b/drunc_docker_service/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# setup dunedaq environment +. /basedir/fddaq-v5.1.0-a9/env.sh + +exec "$@" From 6bfd64f6fc04aa5a980d030ac389cce5ddbb2cfc Mon Sep 17 00:00:00 2001 From: Christopher Cave-Ayland Date: Thu, 17 Oct 2024 15:16:19 +0100 Subject: [PATCH 7/7] Update readme with details of docker compose profiles --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 24f406e..2c04bc0 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,47 @@ This repo defines the web interface for various drunc tools. Including: - The Processes Manager - The Controller -## Running the App +## Docker Setup -_Note that this depends on a very large docker base image._ +This repository provides a Docker Compose configuration providing the requisite services +suitable for development of the interfaces using realistic test data. Working with the +full docker stack requires building a very larger docker base image and has heavy +resource requirements when running. For this reason a "lite" stack is also provided that +can be used for development of the Process Manager UI. -To run with a demo version of the drunc process manager, run it with docker compose: +The full and lite stack are defined using [Docker Compose profiles]. It is recommended +to set the `COMPOSE_PROFILES` environment variable to select which stack you are working +with. Use `COMPOSE_PROFILES=drunc` for the full stack or `COMPOSE_PROFILES=drunc-lite` +for the lite stack. + +You can also use the `--profile` flag when invoking `docker compose` however the +instructions in this file assume you are using the environment variable. + +[Docker Compose profiles]: https://docs.docker.com/compose/how-tos/profiles/ + +## Process Manager UI + +You can use either the full or lite Docker Compose profiles when working with the +Process Manager UI. + +### Getting Started with the Process Manager UI + +Check you have a value set for `COMPOSE_PROFILES` (see above). Start the docker stack +with: ```bash docker compose up ``` -It can take a few moment for the services to boot but the application should then be -available in the browser at . Authentication is required to work -with the application so you need to create a user account to work with: +It can take a few moments for the services to boot but the application should then be +available in the browser at . + +__Note that if you have the Process Manager UI already open in a browser you may see +backtraces from unsuccessful requests generated by the UI. These should stop once drunc +has finished starting up.__ + +Authentication is required to work with the application so you need to create a user +account to work with: ```bash docker compose exec app python manage.py createsuperuser @@ -31,13 +59,20 @@ docker compose exec app python manage.py createsuperuser and follow the prompts. You should then be able to use the details you supplied to pass the login screen. You can use the "boot" button on the main page to create simple -processes to experiment with. You can also do this via the command line: +processes to experiment with. -```bash -docker compose exec app python scripts/talk_to_process_manager.py -``` +Take the services down with `docker compose down` or by pressing Ctrl+C in the +corresponding terminal. + +## Controller UI + +You must use the full Docker Compose profile when working with the Controller UI. -To boot a more realistic test session: +### Getting Started with the Controller UI + +Check you have `COMPOSE_PROFILES=drunc` (see above). As with the Process Manager UI +start the Docker Compose services and create a user account if not already done. You can +then boot a full test session: ```bash docker compose exec drunc /boot_test_session.sh @@ -51,10 +86,8 @@ Once booted you can interact with the root controller via: docker compose exec drunc /entrypoint.sh drunc-controller-shell grpc://localhost:3333 ``` -For details of working with the controller see the [drunc wiki]. - -Take the services down with `docker compose down` or by pressing Ctrl+C in the -corresponding terminal. +For details of working with the controller see the [drunc wiki]. You should also be able +to see the booted processes in the Process Manager UI. [drunc wiki]: https://github.com/DUNE-DAQ/drunc/wiki/Controller