From 0bca2f01701821f93dd8d42820af536a4fac97e2 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Fri, 12 Apr 2024 16:09:18 -0400 Subject: [PATCH 01/13] Update chrisomatic:0.8.2 --- docker-compose_dev.yml | 2 +- docker-compose_noswift.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose_dev.yml b/docker-compose_dev.yml index 27b8fb42..761468fb 100755 --- a/docker-compose_dev.yml +++ b/docker-compose_dev.yml @@ -15,7 +15,7 @@ services: chrisomatic: - image: ghcr.io/fnndsc/chrisomatic:0.8.0a1 + image: ghcr.io/fnndsc/chrisomatic:0.8.2 volumes: - "./chrisomatic:/etc/chrisomatic:ro" - "/var/run/docker.sock:/var/run/docker.sock:rw" diff --git a/docker-compose_noswift.yml b/docker-compose_noswift.yml index 39257b89..cd992d6c 100755 --- a/docker-compose_noswift.yml +++ b/docker-compose_noswift.yml @@ -17,7 +17,7 @@ services: chrisomatic: - image: ghcr.io/fnndsc/chrisomatic:0.8.0a1 + image: ghcr.io/fnndsc/chrisomatic:0.8.2 volumes: - "./chrisomatic:/etc/chrisomatic:ro" - "/var/run/docker.sock:/var/run/docker.sock:rw" From 5d0dace1da2bd8c1c6ac12542ad0fa4e8f95ee68 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Wed, 17 Apr 2024 07:07:14 -0400 Subject: [PATCH 02/13] add docker-compose-dev --- README.md | 88 ++++------ chrisomatic/chrisomatic.yml | 17 +- docker-compose-dev.sh | 8 + docker-compose-dev.yml | 318 ++++++++++++++++++++++++++++++++++++ docker-compose-down.sh | 13 ++ 5 files changed, 378 insertions(+), 66 deletions(-) create mode 100755 docker-compose-dev.sh create mode 100644 docker-compose-dev.yml create mode 100755 docker-compose-down.sh diff --git a/README.md b/README.md index a6e25166..a9c17219 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,22 @@ [![Build](https://github.com/FNNDSC/ChRIS_ultron_backEnd/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/ChRIS_ultron_backEnd/actions/workflows/ci.yml) [![License](https://img.shields.io/github/license/fnndsc/ChRIS_ultron_backEnd.svg)](./LICENSE) +## TL;DR + +To quick start _ChRIS Ultron Back End_: + +``` +./docker-compose-dev.sh +``` + +To shutdown: + +``` +./docker-compose-down.sh +``` + +## Introduction + _ChRIS_ is an open-source platform for containerized medical compute. The _ChRIS_ backend, a.k.a. _ChRIS Ultron Backend_ or _**CUBE**_ for short, is a component of the _ChRIS_ system. @@ -12,7 +28,6 @@ is a component of the _ChRIS_ system. The core backend service for the ChRIS distributed software platform, also known by the anacronym _CUBE_. Internally the service is implemented as a Django-PostgreSQL project offering a [collection+json](http://amundsen.com/media-types/collection/) REST API. Important ancillary components include the ``pfcon`` and ``pman`` file transfer and remote process management microservices. - ## ChRIS development, testing and deployment ### Abstract @@ -38,8 +53,8 @@ macOS is fully supported as a host platform for _CUBE_. Please note that you **m In a word, **don't** (ok, that's technically two words). _CUBE_ is ideally meant to be deployed on Linux/*nix systems. **Windows is not officially supported nor recommended as the host environment**. If you insist on trying on Windows you can consult some unmaintained documentation on attempts to deploy _CUBE_ using the Windows Subsystem for Linux (WSL) [here](https://github.com/FNNDSC/CHRIS_docs/blob/master/workflows/ChRIS_on_WSL.asciidoc). This probably will break. Note that currently no one on the core development uses Windows in much of any capacity so interest or knowledge to help questions about Windows support is low. Nonetheless, we would welcome any brave soul though who has the time and inclination to fully investigate _CUBE_ on Windows deployment. - -#### Install latest Docker and Docker Compose. + +#### Install latest Docker and Docker Compose. Currently tested platforms: * ``Docker 18.06.0+`` @@ -50,66 +65,30 @@ Currently tested platforms: Consult this page https://docs.docker.com/engine/install/linux-postinstall/ -### TL;DR - -#### If you read nothing else on this page, and just want to get an instance of the ChRIS backend services up and running with no mess, no fuss: - -##### The real TL;DR -The all in one copy/paste line to drop into your terminal (assuming of course you are in the repo directory and have the preconditions met): +### Production deployments -```bash -docker swarm leave --force && docker swarm init --advertise-addr 127.0.0.1 && \ -./unmake.sh && sudo rm -fr CHRIS_REMOTE_FS && rm -fr CHRIS_REMOTE_FS && \ -./make.sh -U -I -i -``` +Please refer to https://github.com/FNNDSC/khris-helm -This will start a **bare bones** _CUBE_. This _CUBE_ will **NOT** have any plugins installed. To install a set of plugins, do -```bash -./postscript.sh -``` +### Development -##### Slightly longer but still short TL;DR +#### Quick Start with Docker-compose: -Start a local Docker Swarm cluster if not already started: +Use `docker-compose-dev.sh` to start: -```bash -docker swarm init --advertise-addr 127.0.0.1 ``` - -Get the source code from CUBE repo: - -```bash -git clone https://github.com/FNNDSC/ChRIS_ultron_backend -cd ChRIS_ultron_backend +./docker-compose-dev.sh ``` -Run full CUBE instantiation with tests: -```bash -./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -``` +To shutdown: -Or skip unit and integration tests and the intro: -```bash -./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -U -I -s ``` - -Once the system is "up" you can add more compute plugins to the ecosystem: - -```bash -./postscript.sh +./docker-compose-down.sh ``` -The resulting CUBE instance uses the default Django development server and therefore is not suitable for production. - - -### Production deployments - -Please refer to https://github.com/FNNDSC/khris-helm - - -### Development +##### _CAVEAT_ for mac or linux/arm64 users: + * Some docker images are not available yet. You need to compile the docker images on your own and tag the images as specified in `docker-compose-dev.yml`. #### Docker Swarm-based development environment: @@ -126,7 +105,7 @@ git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git cd ChRIS_ultron_backEnd ./make.sh ``` -All the steps performed by the above script are properly documented in the script itself. +All the steps performed by the above script are properly documented in the script itself. After running this script all the automated tests should have successfully run and a Django development server should be running in interactive mode in this terminal. Later you can stop and remove CUBE services and storage space by running the following bash script from the repository source directory: @@ -143,8 +122,8 @@ docker swarm leave --force #### Kubernetes-based development environment: -Install single-node Kubernetes cluster. -On MAC OS Docker Desktop includes a standalone Kubernetes server and client. +Install single-node Kubernetes cluster. +On MAC OS Docker Desktop includes a standalone Kubernetes server and client. Consult this page https://docs.docker.com/desktop/kubernetes/. On Linux there is a simple MicroK8s installation. Consult this page https://microk8s.io. Then create the required alias: @@ -201,7 +180,7 @@ docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test -- To run all the tests: ```bash -docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test +docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test ``` After running the Integration tests the ``./CHRIS_REMOTE_FS`` directory **must** be empty otherwise it means some error has occurred and you should manually empty it. @@ -215,7 +194,7 @@ docker compose -f docker-compose_dev.yml exec chris_dev coverage run --source=fe docker compose -f docker-compose_dev.yml exec chris_dev coverage report ``` -#### Using [HTTPie](https://httpie.org/) client to play with the REST API +#### Using [HTTPie](https://httpie.org/) client to play with the REST API A simple GET request to retrieve the user-specific list of feeds: ```bash http -a cube:cube1234 http://localhost:8000/api/v1/ @@ -234,7 +213,6 @@ http -a cube:cube1234 http://localhost:8000/api/v1/plugins/instances/1/ swift -A http://127.0.0.1:8080/auth/v1.0 -U chris:chris1234 -K testing list users ``` - ### Documentation #### REST API reference diff --git a/chrisomatic/chrisomatic.yml b/chrisomatic/chrisomatic.yml index ef2520dd..820eb65d 100755 --- a/chrisomatic/chrisomatic.yml +++ b/chrisomatic/chrisomatic.yml @@ -1,30 +1,25 @@ version: 1.2 on: - cube_url: http://chrisdev.local:8000/api/v1/ + cube_url: http://chris:8000/api/v1/ chris_superuser: username: chris password: chris1234 - email: dev@babymri.org cube: - users: - - username: cube - password: cube1234 - email: cube@babymri.org - compute_resource: - name: host - url: "http://pfcon.remote:30005/api/v1/" + url: http://pfcon.host:5005/api/v1/ username: pfcon password: pfcon1234 - description: host Description - innetwork: false - + description: Local compute environment + innetwork: true plugins: - name: pl-simplefsapp - name: pl-dircopy + - name: pl-tsdircopy - name: pl-topologicalcopy + - name: pl-unstack-folders # these two are hard-coded in make.sh to be part of example pipelines - dock_image: fnndsc/pl-simpledsapp diff --git a/docker-compose-dev.sh b/docker-compose-dev.sh new file mode 100755 index 00000000..d562a77c --- /dev/null +++ b/docker-compose-dev.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# change to directory where this script lives +cd "$(dirname "$(readlink -f "$0")")" + +set -ex +docker compose -f docker-compose-dev.yml up -d +exec docker compose -f docker-compose-dev.yml run --rm $notty chrisomatic diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 00000000..27356a55 --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,318 @@ +# an ephemeral instance of ChRIS backend services for local development +# +# warning: /var/run/docker.sock is mounted into some services (notably pman) + +services: + chrisomatic: + image: ghcr.io/fnndsc/chrisomatic:0.8.2 + profiles: + - tools + volumes: + - "./chrisomatic/chrisomatic.yml:/chrisomatic.yml:ro" + - "/var/run/docker.sock:/var/run/docker.sock:rw" + userns_mode: host + depends_on: + - chris + networks: + - local + + db_migrate: + image: ghcr.io/fnndsc/cube:5.0.0 + command: + - sh + - -c + - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && python manage.py migrate --noinput + volumes: + - chris_files:/var/chris:rw + - ./chris_backend:/opt/app-root/src + - .:/opt/ChRIS_ultron_backEnd + environment: + - DJANGO_SETTINGS_MODULE=config.settings.local + - STORAGE_ENV=fslink + depends_on: + chris_dev_db: + condition: service_healthy + networks: + - local + + chris: + container_name: chris + image: ghcr.io/fnndsc/cube:5.0.0 + command: + - sh + - -c + - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && python manage.py runserver 0.0.0.0:8000 + ports: + - "8000:8000" + volumes: + - chris_files:/var/chris:rw + - ./chris_backend:/opt/app-root/src + - .:/opt/ChRIS_ultron_backEnd + environment: + - DJANGO_SETTINGS_MODULE=config.settings.local + - STORAGE_ENV=fslink + depends_on: + db_migrate: + condition: service_completed_successfully + queue: + condition: service_started + networks: + - local + labels: + org.chrisproject.role: "ChRIS_ultron_backEnd" + worker: + image: ghcr.io/fnndsc/cube:5.0.0 + command: + - sh + - -c + - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core worker -c 4 -l info -Q main1,main2 + volumes: + - chris_files:/var/chris:rw + - ./chris_backend:/opt/app-root/src + - .:/opt/ChRIS_ultron_backEnd + environment: + - DJANGO_SETTINGS_MODULE=config.settings.local + - STORAGE_ENV=fslink + depends_on: + db_migrate: + condition: service_completed_successfully + queue: + condition: service_started + pfcon: + condition: service_started + restart: unless-stopped + networks: + - local + worker_periodic: + image: ghcr.io/fnndsc/cube:5.0.0 + command: + - sh + - -c + - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core worker -c 2 -l info -Q periodic + volumes: + - chris_files:/var/chris:rw + - ./chris_backend:/opt/app-root/src + - .:/opt/ChRIS_ultron_backEnd + environment: + - DJANGO_SETTINGS_MODULE=config.settings.local + - STORAGE_ENV=fslink + depends_on: + db_migrate: + condition: service_completed_successfully + queue: + condition: service_started + restart: unless-stopped + networks: + - local + scheduler: + image: ghcr.io/fnndsc/cube:5.0.0 + command: + - sh + - -c + - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler + volumes: + - chris_files:/var/chris:rw + - ./chris_backend:/opt/app-root/src + - .:/opt/ChRIS_ultron_backEnd + environment: + - DJANGO_SETTINGS_MODULE=config.settings.local + - STORAGE_ENV=fslink + depends_on: + db_migrate: + condition: service_completed_successfully + queue: + condition: service_started + restart: unless-stopped + networks: + - local + chris_dev_db: + image: docker.io/library/postgres:16 + restart: unless-stopped + volumes: + - db_data:/var/lib/postgresql/data + environment: + - POSTGRES_DB=chris_dev + - POSTGRES_USER=chris + - POSTGRES_PASSWORD=Chris1234 + networks: + - local + healthcheck: + test: ["CMD", "pg_isready"] + interval: 2s + timeout: 4s + retries: 3 + start_period: 60s + queue: + image: docker.io/library/rabbitmq:3 + restart: unless-stopped + networks: + - local + + pfcon: + container_name: pfcon + image: ghcr.io/fnndsc/pfcon:5.2.2 + environment: + COMPUTE_SERVICE_URL: http://pman:5010/api/v1/ + SECRET_KEY: secret + PFCON_USER: pfcon + PFCON_PASSWORD: pfcon1234 + PFCON_INNETWORK: "true" + STORAGE_ENV: filesystem + STOREBASE_MOUNT: /var/local/storeBase + ports: + - "5005:5005" + volumes: + - chris_files:/var/local/storeBase + networks: + local: + aliases: + - pfcon.host + remote: + labels: + org.chrisproject.role: "pfcon" + user: "1001" + + pman: + image: ghcr.io/fnndsc/pman:6.0.1 + container_name: pman + environment: + CONTAINER_ENV: docker + CONTAINER_USER: "1001:" + ENABLE_HOME_WORKAROUND: "yes" + JOB_LABELS: "org.chrisproject.miniChRIS=plugininstance" + SECRET_KEY: secret + REMOVE_JOBS: "yes" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:rw + depends_on: + - pfcon + ports: + - "5010:5010" + networks: + remote: + userns_mode: "host" + labels: + org.chrisproject.role: "pman" + + chris_ui: + image: ghcr.io/fnndsc/chris_ui:20240410.445-c5ca2f65 + command: sirv --host --single + environment: + REACT_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ + REACT_APP_PFDCM_URL: http://localhost:4005/ + ports: + - "8020:3000" + + orthanc: + image: docker.io/jodogne/orthanc-plugins:1.12.3 + volumes: + - ./orthanc.json:/etc/orthanc/orthanc.json:ro + - orthanc:/var/lib/orthanc/db + ports: + - "4242:4242" + - "8042:8042" + networks: + - pacs + profiles: + - pacs + - orthanc + + pfdcm: + image: ghcr.io/fnndsc/pfdcm:3.1.22 + container_name: pfdcm + environment: + MAX_WORKERS: 1 + volumes: + - pfdcm:/home/dicom:rw + - ./pfdcm-services:/home/dicom/services:ro + - chris_files:/chris_files:rw + ports: + - "4005:4005" + networks: + - pacs + user: "1001" + profiles: + - pacs + pfbridge: + image: docker.io/fnndsc/pfbridge:3.7.8 + container_name: pfbridge + environment: + MAX_WORKERS: 1 + PFLINK_USERNAME: pflink + PFLINK_PASSWORD: pflink1234 + NAME: PFDCMLOCAL + PACSNAME: orthanc + CUBEANDSWIFTKEY: local + ports: + - "33333:33333" + networks: + local: + pflink: + profiles: + - pflink + + pflink: + image: docker.io/fnndsc/pflink:4.0.6 + container_name: pflink + restart: unless-stopped + environment: + PFDCM_NAME: "NOTPFDCMLOCAL" # work around for hard-coded edge case + PFLINK_MONGODB: "mongodb://pflink-db:27017" + PFLINK_PFDCM: "http://pfdcm:4005" + PFLINK_PORT: "4010" + ports: + - "4010:4010" + networks: + local: + pflink: + depends_on: + - pflink-db + profiles: + - pflink + + pflink-db: + image: mongo + environment: + - PUID=1000 + - PGID=1000 + volumes: + - pflink-db-data:/data/db + restart: unless-stopped + networks: + pflink: + profiles: + - pflink + + # Non-root container user workarounds + + cube-nonroot-user-volume-fix: + image: docker.io/library/alpine:latest + volumes: + - chris_files:/data:rw + user: root + command: chmod g+rwx /data + restart: "no" + + pfdcm-nonroot-user-volume-fix: + image: docker.io/library/alpine:latest + volumes: + - pfdcm:/home/dicom:rw + user: root + command: chown 1001 /home/dicom + restart: "no" + +networks: + local: + remote: + pacs: + monitoring: + pflink: + +volumes: + chris_files: + db_data: + orthanc: + pfdcm: + grafana_data: + openobserve_data: + pflink-db-data: diff --git a/docker-compose-down.sh b/docker-compose-down.sh new file mode 100755 index 00000000..8b795f82 --- /dev/null +++ b/docker-compose-down.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# change to directory where this script lives +cd "$(dirname "$(readlink -f "$0")")" + +set -ex + +# remove all plugin instance jobs +pls=$(docker ps -q -a -f 'label=org.chrisproject.miniChRIS=plugininstance') +[ -z "$pls" ] || docker rm -fv $pls + +# stop and remove everything +docker compose -f docker-compose-dev.yml --profile pacs --profile pflink down -v From e9c4dcebc6eb705e7132475afc07228959f377f0 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Tue, 7 May 2024 08:21:26 -0400 Subject: [PATCH 03/13] update chris_ui image to staging --- docker-compose-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 27356a55..c5965221 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -195,7 +195,7 @@ services: org.chrisproject.role: "pman" chris_ui: - image: ghcr.io/fnndsc/chris_ui:20240410.445-c5ca2f65 + image: ghcr.io/fnndsc/chris_ui:staging command: sirv --host --single environment: REACT_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ From 4deb7ed6ce2b1496e3b86d69659c1823f3bf4dd3 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Tue, 7 May 2024 09:26:16 -0400 Subject: [PATCH 04/13] latest-staging --- docker-compose-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index c5965221..239c51c8 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -195,7 +195,7 @@ services: org.chrisproject.role: "pman" chris_ui: - image: ghcr.io/fnndsc/chris_ui:staging + image: ghcr.io/fnndsc/chris_ui:latest-staging command: sirv --host --single environment: REACT_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ From a6f8a1892cd2b3ad6c51bb598c6d521c5d4a7224 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Tue, 7 May 2024 11:02:12 -0400 Subject: [PATCH 05/13] update README.md --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9c17219..4cd8f836 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## TL;DR -To quick start _ChRIS Ultron Back End_: +To quick start _ChRIS Ultron Back End_ development: ``` ./docker-compose-dev.sh @@ -28,6 +28,7 @@ is a component of the _ChRIS_ system. The core backend service for the ChRIS distributed software platform, also known by the anacronym _CUBE_. Internally the service is implemented as a Django-PostgreSQL project offering a [collection+json](http://amundsen.com/media-types/collection/) REST API. Important ancillary components include the ``pfcon`` and ``pman`` file transfer and remote process management microservices. + ## ChRIS development, testing and deployment ### Abstract @@ -65,6 +66,59 @@ Currently tested platforms: Consult this page https://docs.docker.com/engine/install/linux-postinstall/ +### TL;DR + +#### If you read nothing else on this page, and just want to get an instance of the ChRIS backend services up and running with no mess, no fuss: + +##### The real TL;DR + +The all in one copy/paste line to drop into your terminal (assuming of course you are in the repo directory and have the preconditions met): + +```bash +docker swarm leave --force && docker swarm init --advertise-addr 127.0.0.1 && \ +./unmake.sh && sudo rm -fr CHRIS_REMOTE_FS && rm -fr CHRIS_REMOTE_FS && \ +./make.sh -U -I -i +``` + +This will start a **bare bones** _CUBE_. This _CUBE_ will **NOT** have any plugins installed. To install a set of plugins, do + +```bash +./postscript.sh +``` + +##### Slightly longer but still short TL;DR + +Start a local Docker Swarm cluster if not already started: + +```bash +docker swarm init --advertise-addr 127.0.0.1 +``` + +Get the source code from CUBE repo: + +```bash +git clone https://github.com/FNNDSC/ChRIS_ultron_backend +cd ChRIS_ultron_backend +``` + +Run full CUBE instantiation with tests: +```bash +./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh +``` + +Or skip unit and integration tests and the intro: +```bash +./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -U -I -s +``` + +Once the system is "up" you can add more compute plugins to the ecosystem: + +```bash +./postscript.sh +``` + +The resulting CUBE instance uses the default Django development server and therefore is not suitable for production. + ### Production deployments @@ -213,6 +267,7 @@ http -a cube:cube1234 http://localhost:8000/api/v1/plugins/instances/1/ swift -A http://127.0.0.1:8080/auth/v1.0 -U chris:chris1234 -K testing list users ``` + ### Documentation #### REST API reference From 38a3ce26179f946c6c4b34febbf6dad6248904fa Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Tue, 7 May 2024 15:04:34 -0400 Subject: [PATCH 06/13] update REACT_APP_CHRIS_UI_URL to VITE_APP_CHRIS_UI_URL and REACT_APP_PFDCM_URL to VITE_APP_PFDCM_URL --- docker-compose-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 239c51c8..af5aa16b 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -198,8 +198,8 @@ services: image: ghcr.io/fnndsc/chris_ui:latest-staging command: sirv --host --single environment: - REACT_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ - REACT_APP_PFDCM_URL: http://localhost:4005/ + VITE_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ + VITE_APP_PFDCM_URL: http://localhost:4005/ ports: - "8020:3000" From e463a76dd5dbb441f529f79a60c504ece7b70157 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Tue, 7 May 2024 15:56:29 -0400 Subject: [PATCH 07/13] add cube_local for building cube:latest-local before starting other cube containers --- docker-compose-dev.yml | 60 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index af5aa16b..05eae34a 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -16,20 +16,34 @@ services: networks: - local + cube_local: + image: cube:latest-local + build: + context: . + dockerfile_inline: | + FROM ghcr.io/fnndsc/cube:latest + + RUN mkdir -p /opt + COPY ./requirements /opt/requirements + RUN pip install -r /opt/requirements/local.txt + command: sh -c 'exit 0' + db_migrate: - image: ghcr.io/fnndsc/cube:5.0.0 + image: cube:latest-local command: - sh - -c - - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && python manage.py migrate --noinput + - python manage.py migrate --noinput volumes: - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src - - .:/opt/ChRIS_ultron_backEnd + - ./chris_backend:/opt/app-root/src:ro + - .:/opt/ChRIS_ultron_backEnd:ro environment: - DJANGO_SETTINGS_MODULE=config.settings.local - STORAGE_ENV=fslink depends_on: + cube_local: + condition: service_completed_successfully chris_dev_db: condition: service_healthy networks: @@ -37,21 +51,23 @@ services: chris: container_name: chris - image: ghcr.io/fnndsc/cube:5.0.0 + image: cube:latest-local command: - sh - -c - - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && python manage.py runserver 0.0.0.0:8000 + - python manage.py runserver 0.0.0.0:8000 ports: - "8000:8000" volumes: - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src - - .:/opt/ChRIS_ultron_backEnd + - ./chris_backend:/opt/app-root/src:ro + - .:/opt/ChRIS_ultron_backEnd:ro environment: - DJANGO_SETTINGS_MODULE=config.settings.local - STORAGE_ENV=fslink depends_on: + cube_local: + condition: service_completed_successfully db_migrate: condition: service_completed_successfully queue: @@ -61,15 +77,15 @@ services: labels: org.chrisproject.role: "ChRIS_ultron_backEnd" worker: - image: ghcr.io/fnndsc/cube:5.0.0 + image: cube:latest-local command: - sh - -c - - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core worker -c 4 -l info -Q main1,main2 + - celery -A core worker -c 4 -l info -Q main1,main2 volumes: - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src - - .:/opt/ChRIS_ultron_backEnd + - ./chris_backend:/opt/app-root/src:ro + - .:/opt/ChRIS_ultron_backEnd:ro environment: - DJANGO_SETTINGS_MODULE=config.settings.local - STORAGE_ENV=fslink @@ -84,19 +100,21 @@ services: networks: - local worker_periodic: - image: ghcr.io/fnndsc/cube:5.0.0 + image: cube:latest-local command: - sh - -c - - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core worker -c 2 -l info -Q periodic + - celery -A core worker -c 2 -l info -Q periodic volumes: - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src - - .:/opt/ChRIS_ultron_backEnd + - ./chris_backend:/opt/app-root/src:ro + - .:/opt/ChRIS_ultron_backEnd:ro environment: - DJANGO_SETTINGS_MODULE=config.settings.local - STORAGE_ENV=fslink depends_on: + cube_local: + condition: service_completed_successfully db_migrate: condition: service_completed_successfully queue: @@ -105,19 +123,21 @@ services: networks: - local scheduler: - image: ghcr.io/fnndsc/cube:5.0.0 + image: cube:latest-local command: - sh - -c - - pip install -r /opt/ChRIS_ultron_backEnd/requirements/local.txt && celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler + - celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler volumes: - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src - - .:/opt/ChRIS_ultron_backEnd + - ./chris_backend:/opt/app-root/src:ro + - .:/opt/ChRIS_ultron_backEnd:ro environment: - DJANGO_SETTINGS_MODULE=config.settings.local - STORAGE_ENV=fslink depends_on: + cube_local: + condition: service_completed_successfully db_migrate: condition: service_completed_successfully queue: From a9db8351ea4f40a1075a17b92019f9699f088c2c Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Wed, 8 May 2024 13:18:12 -0400 Subject: [PATCH 08/13] update pman to 6.2.0 --- docker-compose-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 05eae34a..c14838b7 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -193,7 +193,7 @@ services: user: "1001" pman: - image: ghcr.io/fnndsc/pman:6.0.1 + image: ghcr.io/fnndsc/pman:6.2.0 container_name: pman environment: CONTAINER_ENV: docker From 5fa34e8936248fece9f5a0204bd289739e632f6a Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Wed, 28 Aug 2024 23:52:45 -0400 Subject: [PATCH 09/13] Add justfile --- .github/workflows/ci.yml | 18 +- OLD_DEVELOP.md | 206 +++++++++++++++ README.md | 297 ++++++---------------- chris_backend/config/settings/local.py | 2 +- docker-compose-dev.yml | 338 ------------------------- docker-compose_just.yml | 178 +++++++++++++ justfile | 82 ++++++ 7 files changed, 557 insertions(+), 564 deletions(-) create mode 100644 OLD_DEVELOP.md delete mode 100644 docker-compose-dev.yml create mode 100644 docker-compose_just.yml create mode 100644 justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18a07d75..5bb91224 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,19 +10,23 @@ on: jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - uses: FNNDSC/cube-integration-action@master - with: - repository: ${{ github.workspace }} - which: all - + - uses: taiki-e/install-action@just + - name: Build development image + run: just build + - name: Pull other images + run: just pull + - name: Run unit tests + run: just test-unit + - name: Run integration tests + run: just test-integration build: needs: [ test ] if: github.event_name == 'push' || github.event_name == 'release' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 env: repo_name: fnndsc/cube steps: diff --git a/OLD_DEVELOP.md b/OLD_DEVELOP.md new file mode 100644 index 00000000..1d05bc8b --- /dev/null +++ b/OLD_DEVELOP.md @@ -0,0 +1,206 @@ +# ChRIS\_ultron\_backEnd Old Development Scripts + +### Preconditions + +#### Operating system support -- please read + +##### Linux + +Linux is the first class host platform for all things _CUBE_ related. Linux distributions used by various core developers include Ubuntu, Arch, and Fedora. The development team is happy to provide help to folks trying / struggling to run _CUBE_ on most any Linux distribution. + +##### macOS + +macOS is fully supported as a host platform for _CUBE_. Please note that you **must update/tweak some things first**. Most importantly, macOS is distributed with a deprecated version of the `bash` shell **that will not work with our Makefile**. If you want to host _CUBE_ on macOS, you **must** update `bash` to a current version. Instructions are out of scope of this document, but we recommend [homebrew](https://brew.sh) as your friend here. + +##### Windows + +In a word, **don't** (ok, that's technically two words). _CUBE_ is ideally meant to be deployed on Linux/*nix systems. **Windows is not officially supported nor recommended as the host environment**. If you insist on trying on Windows you can consult some unmaintained documentation on attempts to deploy _CUBE_ using the Windows Subsystem for Linux (WSL) [here](https://github.com/FNNDSC/CHRIS_docs/blob/master/workflows/ChRIS_on_WSL.asciidoc). This probably will break. Note that currently no one on the core development uses Windows in much of any capacity so interest or knowledge to help questions about Windows support is low. Nonetheless, we would welcome any brave soul though who has the time and inclination to fully investigate _CUBE_ on Windows deployment. + + +#### Install latest Docker and Docker Compose. + +Currently tested platforms: +* ``Docker 18.06.0+`` +* ``Docker Compose 1.27.0+`` +* ``Ubuntu 18.04+ and MAC OS X 10.14+`` + +#### On a Linux machine make sure to add your computer user to the ``docker`` group + +Consult this page https://docs.docker.com/engine/install/linux-postinstall/ + +### TL;DR + +#### If you read nothing else on this page, and just want to get an instance of the ChRIS backend services up and running with no mess, no fuss: + +##### The real TL;DR + +The all in one copy/paste line to drop into your terminal (assuming of course you are in the repo directory and have the preconditions met): + +```bash +docker swarm leave --force && docker swarm init --advertise-addr 127.0.0.1 && \ +./unmake.sh && sudo rm -fr CHRIS_REMOTE_FS && rm -fr CHRIS_REMOTE_FS && \ +./make.sh -U -I -i +``` + +This will start a **bare bones** _CUBE_. This _CUBE_ will **NOT** have any plugins installed. To install a set of plugins, do + +```bash +./postscript.sh +``` + +##### Slightly longer but still short TL;DR + +Start a local Docker Swarm cluster if not already started: + +```bash +docker swarm init --advertise-addr 127.0.0.1 +``` + +Get the source code from CUBE repo: + +```bash +git clone https://github.com/FNNDSC/ChRIS_ultron_backend +cd ChRIS_ultron_backend +``` + +Run full CUBE instantiation with tests: +```bash +./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh +``` + +Or skip unit and integration tests and the intro: +```bash +./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -U -I -s +``` + +Once the system is "up" you can add more compute plugins to the ecosystem: + +```bash +./postscript.sh +``` + +The resulting CUBE instance uses the default Django development server and therefore is not suitable for production. + + +#### Docker Swarm-based development environment: + +Start a local Docker Swarm cluster if not already started: + +```bash +docker swarm init --advertise-addr 127.0.0.1 +``` + +Start CUBE from the repository source directory by running the make bash script + +```bash +git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git +cd ChRIS_ultron_backEnd +./make.sh +``` +All the steps performed by the above script are properly documented in the script itself. +After running this script all the automated tests should have successfully run and a Django development server should be running in interactive mode in this terminal. + +Later you can stop and remove CUBE services and storage space by running the following bash script from the repository source directory: + +```bash +./unmake.sh +``` + +Then remove the local Docker Swarm cluster if desired: + +```bash +docker swarm leave --force +``` + +#### Kubernetes-based development environment: + +Install single-node Kubernetes cluster. +On MAC OS Docker Desktop includes a standalone Kubernetes server and client. +Consult this page https://docs.docker.com/desktop/kubernetes/. +On Linux there is a simple MicroK8s installation. Consult this page https://microk8s.io. +Then create the required alias: + +```bash +snap alias microk8s.kubectl kubectl +microk8s.kubectl config view --raw > $HOME/.kube/config +``` + +Start the Kubernetes cluster: + +```bash +microk8s start +``` + +Start CUBE from the repository source directory by running the make bash script + +```bash +git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git +cd ChRIS_ultron_backEnd +export HOSTIP= +./make.sh -O kubernetes +``` + +Later you can stop and remove CUBE services and storage space by running the following bash script from the repository source directory: + +```bash +./unmake.sh -O kubernetes +``` + +Stop the Kubernetes cluster if desired: + +```bash +microk8s stop +``` + +#### Rerun automated tests after modifying source code + +Open another terminal and run the Unit and Integration tests within the container running the Django server: + +To run only the Unit tests: + +```bash +cd ChRIS_ultron_backEnd +docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test --exclude-tag integration +``` + +To run only the Integration tests: + +```bash +docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test --tag integration +``` + +To run all the tests: + +```bash +docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test +``` + +After running the Integration tests the ``./CHRIS_REMOTE_FS`` directory **must** be empty otherwise it means some error has occurred and you should manually empty it. + + +#### Check code coverage of the automated tests +Make sure the ``chris_backend/`` dir is world writable. Then type: + +```bash +docker compose -f docker-compose_dev.yml exec chris_dev coverage run --source=feeds,plugins,userfiles,users manage.py test +docker compose -f docker-compose_dev.yml exec chris_dev coverage report +``` + +#### Using [HTTPie](https://httpie.org/) client to play with the REST API +A simple GET request to retrieve the user-specific list of feeds: +```bash +http -a cube:cube1234 http://localhost:8000/api/v1/ +``` +A simple POST request to run the plugin with id 1: +```bash +http -a cube:cube1234 POST http://localhost:8000/api/v1/plugins/1/instances/ Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json template:='{"data":[{"name":"dir","value":"cube/"}]}' +``` +Then keep making the following GET request until the ``"status"`` descriptor in the response becomes ``"finishedSuccessfully"``: +```bash +http -a cube:cube1234 http://localhost:8000/api/v1/plugins/instances/1/ +``` + +#### Using swift client to list files in the users bucket +```bash +swift -A http://127.0.0.1:8080/auth/v1.0 -U chris:chris1234 -K testing list users +``` diff --git a/README.md b/README.md index 4cd8f836..a9ec62cb 100755 --- a/README.md +++ b/README.md @@ -1,274 +1,143 @@ -# ![ChRIS logo](https://github.com/FNNDSC/ChRIS_ultron_backEnd/blob/master/docs/assets/logo_chris.png) ChRIS\_ultron\_backEnd +# ![ChRIS logo](./docs/assets/logo_chris.png) ChRIS\_ultron\_backEnd [![Build](https://github.com/FNNDSC/ChRIS_ultron_backEnd/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/ChRIS_ultron_backEnd/actions/workflows/ci.yml) [![License](https://img.shields.io/github/license/fnndsc/ChRIS_ultron_backEnd.svg)](./LICENSE) -## TL;DR - -To quick start _ChRIS Ultron Back End_ development: - -``` -./docker-compose-dev.sh -``` - -To shutdown: +_ChRIS_ is an open-source platform for containerized medical compute. -``` -./docker-compose-down.sh -``` +https://chrisproject.org/ ## Introduction -_ChRIS_ is an open-source platform for containerized medical compute. The _ChRIS_ backend, a.k.a. _ChRIS Ultron Backend_ or _**CUBE**_ for short, -is a component of the _ChRIS_ system. - -![Architecture Diagram](https://chrisproject.org/img/figures/ChRIS_architecture.svg#gh-light-mode-only) -![Architecture Diagram](https://chrisproject.org/img/figures/ChRIS_architecture_dark.svg#gh-dark-mode-only) - -The core backend service for the ChRIS distributed software platform, also known by the anacronym _CUBE_. Internally the service is implemented as a Django-PostgreSQL project offering a [collection+json](http://amundsen.com/media-types/collection/) REST API. Important ancillary components include the ``pfcon`` and ``pman`` file transfer and remote process management microservices. - - -## ChRIS development, testing and deployment - -### Abstract - -_ChRIS Ultron Back End_ (sometimes also _ChRIS Underlying Back End_) or simply _CUBE_ is the main core of the ChRIS system. _CUBE_ provides the main REST API to the ChRIS system, as well as maintaining an internal database of users, files, pipelines, and plugins. Currently _CUBE_ has two separate compute paradigms depending on deployment context. In the case of _development_ all components of _CUBE_ use `docker` and `docker swarm` technologies. In the case of _production_ technologies such as `openshift` and `kubernetes` are also supported. - -Consult this page for instructions on starting _CUBE_ in either _development_ or _production_ contexts. For documentation/overview/background, please see the [documention](https://github.com/FNNDSC/ChRIS_docs). - - -### Preconditions - -#### Operating system support -- please read - -##### Linux - -Linux is the first class host platform for all things _CUBE_ related. Linux distributions used by various core developers include Ubuntu, Arch, and Fedora. The development team is happy to provide help to folks trying / struggling to run _CUBE_ on most any Linux distribution. - -##### macOS - -macOS is fully supported as a host platform for _CUBE_. Please note that you **must update/tweak some things first**. Most importantly, macOS is distributed with a deprecated version of the `bash` shell **that will not work with our Makefile**. If you want to host _CUBE_ on macOS, you **must** update `bash` to a current version. Instructions are out of scope of this document, but we recommend [homebrew](https://brew.sh) as your friend here. - -##### Windows - -In a word, **don't** (ok, that's technically two words). _CUBE_ is ideally meant to be deployed on Linux/*nix systems. **Windows is not officially supported nor recommended as the host environment**. If you insist on trying on Windows you can consult some unmaintained documentation on attempts to deploy _CUBE_ using the Windows Subsystem for Linux (WSL) [here](https://github.com/FNNDSC/CHRIS_docs/blob/master/workflows/ChRIS_on_WSL.asciidoc). This probably will break. Note that currently no one on the core development uses Windows in much of any capacity so interest or knowledge to help questions about Windows support is low. Nonetheless, we would welcome any brave soul though who has the time and inclination to fully investigate _CUBE_ on Windows deployment. - - -#### Install latest Docker and Docker Compose. - -Currently tested platforms: -* ``Docker 18.06.0+`` -* ``Docker Compose 1.27.0+`` -* ``Ubuntu 18.04+ and MAC OS X 10.14+`` - -#### On a Linux machine make sure to add your computer user to the ``docker`` group - -Consult this page https://docs.docker.com/engine/install/linux-postinstall/ - -### TL;DR - -#### If you read nothing else on this page, and just want to get an instance of the ChRIS backend services up and running with no mess, no fuss: - -##### The real TL;DR - -The all in one copy/paste line to drop into your terminal (assuming of course you are in the repo directory and have the preconditions met): - -```bash -docker swarm leave --force && docker swarm init --advertise-addr 127.0.0.1 && \ -./unmake.sh && sudo rm -fr CHRIS_REMOTE_FS && rm -fr CHRIS_REMOTE_FS && \ -./make.sh -U -I -i -``` - -This will start a **bare bones** _CUBE_. This _CUBE_ will **NOT** have any plugins installed. To install a set of plugins, do +is a component of the _ChRIS_ system. It is responsible for maintaining the database +of users, files, plugins, and pipelines. -```bash -./postscript.sh -``` - -##### Slightly longer but still short TL;DR - -Start a local Docker Swarm cluster if not already started: - -```bash -docker swarm init --advertise-addr 127.0.0.1 -``` + + + + Architecture diagram + -Get the source code from CUBE repo: +Here lives the code of _CUBE_. It is a Django project using PostgreSQL and Celery. +The HTTP API primarily supports the [collection+json](http://amundsen.com/media-types/collection/) content-type. -```bash -git clone https://github.com/FNNDSC/ChRIS_ultron_backend -cd ChRIS_ultron_backend -``` +## Development -Run full CUBE instantiation with tests: -```bash -./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -``` +Development is mainly supported on Linux. MacOS and WSL on Windows also work (because Docker Desktop is a Linux VM). You will need at least 8GM RAM, 20GB disk space, and a good internet connection. -Or skip unit and integration tests and the intro: -```bash -./unmake.sh ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS; ./make.sh -U -I -s -``` +Install Docker (version 27 or above), Docker Compose, and [just](https://github.com/casey/just?tab=readme-ov-file#installation). -Once the system is "up" you can add more compute plugins to the ecosystem: - -```bash -./postscript.sh -``` +
+ +Docker Installation Instructions + -The resulting CUBE instance uses the default Django development server and therefore is not suitable for production. +- For MacOS and Windows, see: https://docs.docker.com/get-started/get-docker/ +- For Linux, see: https://docs.docker.com/engine/install/ +> [!CAUTION] +> On **Linux**, the official Docker Documentation will try to trick you into installing "Docker Desktop." Do not install "Docker Desktop." Look for "Docker Engine" instead. -### Production deployments +> [!CAUTION] +> On **Ubuntu**, make sure you follow the instructions here: https://docs.docker.com/engine/install/ubuntu/. If you do not follow the instructions, Ubuntu will try to install Docker using snap, which will cause many problems. -Please refer to https://github.com/FNNDSC/khris-helm +
+### Just Commands -### Development +Development is handled by [`just`](https://just.systems). +Running _CUBE_ in development mode is as-simple-as running the command -#### Quick Start with Docker-compose: - -Use `docker-compose-dev.sh` to start: - -``` -./docker-compose-dev.sh +```shell +just ``` -To shutdown: +The first run of `just` will take 5-20 minutes because it needs to pull and build container images. Subsequent runs should only take 1-5 minutes. -``` -./docker-compose-down.sh -``` +_CUBE_ is now running at http://localhost:8000/api/v1/. You can click around in the web browser. Alternatively, check out [chrs](https://chrisproject.org/docs/chrs) and/or [ChRIS\_ui](https://github.com/FNNDSC/ChRIS_ui). -##### _CAVEAT_ for mac or linux/arm64 users: - * Some docker images are not available yet. You need to compile the docker images on your own and tag the images as specified in `docker-compose-dev.yml`. +Run tests: -#### Docker Swarm-based development environment: - -Start a local Docker Swarm cluster if not already started: - -```bash -docker swarm init --advertise-addr 127.0.0.1 +```shell +just test-all # run all tests +just test-unit # run unit tests +just test-integration # run integration tests +just test feeds.tests.test_views # run chris_backend/feeds/tests/test_views.py ``` -Start CUBE from the repository source directory by running the make bash script +Shut down and clean up: -```bash -git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git -cd ChRIS_ultron_backEnd -./make.sh +```shell +just nuke ``` -All the steps performed by the above script are properly documented in the script itself. -After running this script all the automated tests should have successfully run and a Django development server should be running in interactive mode in this terminal. -Later you can stop and remove CUBE services and storage space by running the following bash script from the repository source directory: +List all `just` commands: -```bash -./unmake.sh +```shell +just --list --unsorted ``` -Then remove the local Docker Swarm cluster if desired: - -```bash -docker swarm leave --force -``` +### Development Tips and Tricks -#### Kubernetes-based development environment: +#### Recreate containers after changing `docker-compose_just.yml` -Install single-node Kubernetes cluster. -On MAC OS Docker Desktop includes a standalone Kubernetes server and client. -Consult this page https://docs.docker.com/desktop/kubernetes/. -On Linux there is a simple MicroK8s installation. Consult this page https://microk8s.io. -Then create the required alias: +If you modify `docker-compose_just.yml`, you need to recreate/restart the affected services. -```bash -snap alias microk8s.kubectl kubectl -microk8s.kubectl config view --raw > $HOME/.kube/config +```shell +just up ``` -Start the Kubernetes cluster: +#### Rebuild the image after changing package dependencies -```bash -microk8s start -``` - -Start CUBE from the repository source directory by running the make bash script +If you modify `Dockerfile` or `requirements/*.txt`, you need to rebuild the image and recreate your containers. -```bash -git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git -cd ChRIS_ultron_backEnd -export HOSTIP= -./make.sh -O kubernetes +```shell +just rebuild && just up ``` -Later you can stop and remove CUBE services and storage space by running the following bash script from the repository source directory: +#### Trying HTTP requests from the CLI -```bash -./unmake.sh -O kubernetes -``` +For CLI tools, I recommend [xh](https://github.com/ducaale/xh) and [jnv](https://github.com/ynqa/jnv) or [jq](https://jqlang.github.io/jq/). Example: -Stop the Kubernetes cluster if desired: - -```bash -microk8s stop +```shell +xh -a chris:chris1234 :8000/api/v1/ | jnv ``` -#### Rerun automated tests after modifying source code - -Open another terminal and run the Unit and Integration tests within the container running the Django server: +#### Interactive shell -To run only the Unit tests: +It is often easiest to debug things using a shell. -```bash -cd ChRIS_ultron_backEnd -docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test --exclude-tag integration +```shell +just bash # run bash in a container +# -- or -- +just shell # run a Python REPL ``` -To run only the Integration tests: +In the Python REPL, you can import models and interact with them. Here is some common starter code: -```bash -docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test --tag integration -``` - -To run all the tests: +```python +from django.conf import settings +from django.contrib.auth.models import User, Group +from plugins.models import * +from plugininstances.models import * +from core.storage import connect_storage -```bash -docker compose -f docker-compose_dev.yml exec chris_dev python manage.py test +storage = connect_storage(settings) ``` -After running the Integration tests the ``./CHRIS_REMOTE_FS`` directory **must** be empty otherwise it means some error has occurred and you should manually empty it. - - -#### Check code coverage of the automated tests -Make sure the ``chris_backend/`` dir is world writable. Then type: +### Alternative Development Script -```bash -docker compose -f docker-compose_dev.yml exec chris_dev coverage run --source=feeds,plugins,userfiles,users manage.py test -docker compose -f docker-compose_dev.yml exec chris_dev coverage report -``` +Old development scripts usage is described in [OLD_DEVELOP.md](./OLD_DEVELOP.md). -#### Using [HTTPie](https://httpie.org/) client to play with the REST API -A simple GET request to retrieve the user-specific list of feeds: -```bash -http -a cube:cube1234 http://localhost:8000/api/v1/ -``` -A simple POST request to run the plugin with id 1: -```bash -http -a cube:cube1234 POST http://localhost:8000/api/v1/plugins/1/instances/ Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json template:='{"data":[{"name":"dir","value":"cube/"}]}' -``` -Then keep making the following GET request until the ``"status"`` descriptor in the response becomes ``"finishedSuccessfully"``: -```bash -http -a cube:cube1234 http://localhost:8000/api/v1/plugins/instances/1/ -``` +## Production Deployment -#### Using swift client to list files in the users bucket -```bash -swift -A http://127.0.0.1:8080/auth/v1.0 -U chris:chris1234 -K testing list users -``` +See https://chrisproject.org/docs/run/helm +## Documentation -### Documentation +> [!CAUTION] +> Everything below in this section is outdated. #### REST API reference @@ -293,11 +162,3 @@ Available [here](https://github.com/FNNDSC/ChRIS_ultron_backEnd/wiki/ChRIS-REST- #### ChRIS backend database design. Available [here](https://github.com/FNNDSC/ChRIS_ultron_backEnd/wiki/ChRIS-backend-database-design). - -#### Wiki. - -Available [here](https://github.com/FNNDSC/ChRIS_ultron_backEnd/wiki). - -### Learn More - -If you are interested in contributing or joining us, Check [here](http://chrisproject.org/join-us). diff --git a/chris_backend/config/settings/local.py b/chris_backend/config/settings/local.py index 29ce2c00..296cd494 100755 --- a/chris_backend/config/settings/local.py +++ b/chris_backend/config/settings/local.py @@ -101,7 +101,7 @@ MEDIA_ROOT = None if STORAGE_ENV in ('fslink', 'filesystem'): STORAGES['default'] = {'BACKEND': 'django.core.files.storage.FileSystemStorage'} - MEDIA_ROOT = '/var/chris' # local filesystem storage settings + MEDIA_ROOT = '/data' # local filesystem storage settings try: verify_storage_connection( diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml deleted file mode 100644 index c14838b7..00000000 --- a/docker-compose-dev.yml +++ /dev/null @@ -1,338 +0,0 @@ -# an ephemeral instance of ChRIS backend services for local development -# -# warning: /var/run/docker.sock is mounted into some services (notably pman) - -services: - chrisomatic: - image: ghcr.io/fnndsc/chrisomatic:0.8.2 - profiles: - - tools - volumes: - - "./chrisomatic/chrisomatic.yml:/chrisomatic.yml:ro" - - "/var/run/docker.sock:/var/run/docker.sock:rw" - userns_mode: host - depends_on: - - chris - networks: - - local - - cube_local: - image: cube:latest-local - build: - context: . - dockerfile_inline: | - FROM ghcr.io/fnndsc/cube:latest - - RUN mkdir -p /opt - COPY ./requirements /opt/requirements - RUN pip install -r /opt/requirements/local.txt - command: sh -c 'exit 0' - - db_migrate: - image: cube:latest-local - command: - - sh - - -c - - python manage.py migrate --noinput - volumes: - - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src:ro - - .:/opt/ChRIS_ultron_backEnd:ro - environment: - - DJANGO_SETTINGS_MODULE=config.settings.local - - STORAGE_ENV=fslink - depends_on: - cube_local: - condition: service_completed_successfully - chris_dev_db: - condition: service_healthy - networks: - - local - - chris: - container_name: chris - image: cube:latest-local - command: - - sh - - -c - - python manage.py runserver 0.0.0.0:8000 - ports: - - "8000:8000" - volumes: - - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src:ro - - .:/opt/ChRIS_ultron_backEnd:ro - environment: - - DJANGO_SETTINGS_MODULE=config.settings.local - - STORAGE_ENV=fslink - depends_on: - cube_local: - condition: service_completed_successfully - db_migrate: - condition: service_completed_successfully - queue: - condition: service_started - networks: - - local - labels: - org.chrisproject.role: "ChRIS_ultron_backEnd" - worker: - image: cube:latest-local - command: - - sh - - -c - - celery -A core worker -c 4 -l info -Q main1,main2 - volumes: - - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src:ro - - .:/opt/ChRIS_ultron_backEnd:ro - environment: - - DJANGO_SETTINGS_MODULE=config.settings.local - - STORAGE_ENV=fslink - depends_on: - db_migrate: - condition: service_completed_successfully - queue: - condition: service_started - pfcon: - condition: service_started - restart: unless-stopped - networks: - - local - worker_periodic: - image: cube:latest-local - command: - - sh - - -c - - celery -A core worker -c 2 -l info -Q periodic - volumes: - - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src:ro - - .:/opt/ChRIS_ultron_backEnd:ro - environment: - - DJANGO_SETTINGS_MODULE=config.settings.local - - STORAGE_ENV=fslink - depends_on: - cube_local: - condition: service_completed_successfully - db_migrate: - condition: service_completed_successfully - queue: - condition: service_started - restart: unless-stopped - networks: - - local - scheduler: - image: cube:latest-local - command: - - sh - - -c - - celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler - volumes: - - chris_files:/var/chris:rw - - ./chris_backend:/opt/app-root/src:ro - - .:/opt/ChRIS_ultron_backEnd:ro - environment: - - DJANGO_SETTINGS_MODULE=config.settings.local - - STORAGE_ENV=fslink - depends_on: - cube_local: - condition: service_completed_successfully - db_migrate: - condition: service_completed_successfully - queue: - condition: service_started - restart: unless-stopped - networks: - - local - chris_dev_db: - image: docker.io/library/postgres:16 - restart: unless-stopped - volumes: - - db_data:/var/lib/postgresql/data - environment: - - POSTGRES_DB=chris_dev - - POSTGRES_USER=chris - - POSTGRES_PASSWORD=Chris1234 - networks: - - local - healthcheck: - test: ["CMD", "pg_isready"] - interval: 2s - timeout: 4s - retries: 3 - start_period: 60s - queue: - image: docker.io/library/rabbitmq:3 - restart: unless-stopped - networks: - - local - - pfcon: - container_name: pfcon - image: ghcr.io/fnndsc/pfcon:5.2.2 - environment: - COMPUTE_SERVICE_URL: http://pman:5010/api/v1/ - SECRET_KEY: secret - PFCON_USER: pfcon - PFCON_PASSWORD: pfcon1234 - PFCON_INNETWORK: "true" - STORAGE_ENV: filesystem - STOREBASE_MOUNT: /var/local/storeBase - ports: - - "5005:5005" - volumes: - - chris_files:/var/local/storeBase - networks: - local: - aliases: - - pfcon.host - remote: - labels: - org.chrisproject.role: "pfcon" - user: "1001" - - pman: - image: ghcr.io/fnndsc/pman:6.2.0 - container_name: pman - environment: - CONTAINER_ENV: docker - CONTAINER_USER: "1001:" - ENABLE_HOME_WORKAROUND: "yes" - JOB_LABELS: "org.chrisproject.miniChRIS=plugininstance" - SECRET_KEY: secret - REMOVE_JOBS: "yes" - volumes: - - /var/run/docker.sock:/var/run/docker.sock:rw - depends_on: - - pfcon - ports: - - "5010:5010" - networks: - remote: - userns_mode: "host" - labels: - org.chrisproject.role: "pman" - - chris_ui: - image: ghcr.io/fnndsc/chris_ui:latest-staging - command: sirv --host --single - environment: - VITE_APP_CHRIS_UI_URL: http://localhost:8000/api/v1/ - VITE_APP_PFDCM_URL: http://localhost:4005/ - ports: - - "8020:3000" - - orthanc: - image: docker.io/jodogne/orthanc-plugins:1.12.3 - volumes: - - ./orthanc.json:/etc/orthanc/orthanc.json:ro - - orthanc:/var/lib/orthanc/db - ports: - - "4242:4242" - - "8042:8042" - networks: - - pacs - profiles: - - pacs - - orthanc - - pfdcm: - image: ghcr.io/fnndsc/pfdcm:3.1.22 - container_name: pfdcm - environment: - MAX_WORKERS: 1 - volumes: - - pfdcm:/home/dicom:rw - - ./pfdcm-services:/home/dicom/services:ro - - chris_files:/chris_files:rw - ports: - - "4005:4005" - networks: - - pacs - user: "1001" - profiles: - - pacs - pfbridge: - image: docker.io/fnndsc/pfbridge:3.7.8 - container_name: pfbridge - environment: - MAX_WORKERS: 1 - PFLINK_USERNAME: pflink - PFLINK_PASSWORD: pflink1234 - NAME: PFDCMLOCAL - PACSNAME: orthanc - CUBEANDSWIFTKEY: local - ports: - - "33333:33333" - networks: - local: - pflink: - profiles: - - pflink - - pflink: - image: docker.io/fnndsc/pflink:4.0.6 - container_name: pflink - restart: unless-stopped - environment: - PFDCM_NAME: "NOTPFDCMLOCAL" # work around for hard-coded edge case - PFLINK_MONGODB: "mongodb://pflink-db:27017" - PFLINK_PFDCM: "http://pfdcm:4005" - PFLINK_PORT: "4010" - ports: - - "4010:4010" - networks: - local: - pflink: - depends_on: - - pflink-db - profiles: - - pflink - - pflink-db: - image: mongo - environment: - - PUID=1000 - - PGID=1000 - volumes: - - pflink-db-data:/data/db - restart: unless-stopped - networks: - pflink: - profiles: - - pflink - - # Non-root container user workarounds - - cube-nonroot-user-volume-fix: - image: docker.io/library/alpine:latest - volumes: - - chris_files:/data:rw - user: root - command: chmod g+rwx /data - restart: "no" - - pfdcm-nonroot-user-volume-fix: - image: docker.io/library/alpine:latest - volumes: - - pfdcm:/home/dicom:rw - user: root - command: chown 1001 /home/dicom - restart: "no" - -networks: - local: - remote: - pacs: - monitoring: - pflink: - -volumes: - chris_files: - db_data: - orthanc: - pfdcm: - grafana_data: - openobserve_data: - pflink-db-data: diff --git a/docker-compose_just.yml b/docker-compose_just.yml new file mode 100644 index 00000000..98e2f253 --- /dev/null +++ b/docker-compose_just.yml @@ -0,0 +1,178 @@ +# Docker Compose file for ChRIS backend development. +# See justfile for usage. *DO NOT* use the `docker compose` command directly. + +services: + chrisomatic: + image: ghcr.io/fnndsc/chrisomatic:1.0.0 + profiles: + - tools + volumes: + - "./chrisomatic/chrisomatic.yml:/chrisomatic.yml" + - "/var/run/docker.sock:/var/run/docker.sock" + userns_mode: host + depends_on: + - chris + networks: + - local + + chris: + image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev} + build: + context: . + args: + ENVIRONMENT: local + command: python manage.py runserver 0.0.0.0:8000 + ports: + - "8000:8000" + volumes: &CHRIS_VOLUMES + - chris_files:/data + - ./chris_backend:/opt/app-root/src + environment: &CHRIS_ENV + DJANGO_SETTINGS_MODULE: "config.settings.local" + STORAGE_ENV: "fslink" + user: ${UID:?Please run me using just.}:${GID:?Please run me using just.} + profiles: + - cube + depends_on: &CHRIS_DEPENDS + db: + condition: service_healthy + rabbitmq: + condition: service_started + cube-nonroot-user-volume-fix: + condition: service_completed_successfully + networks: + - local + worker-mains: + image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev} + command: celery -A core worker -c 4 -l info -Q main1,main2 + volumes: *CHRIS_VOLUMES + environment: *CHRIS_ENV + user: ${UID}:${GID} + profiles: + - cube + depends_on: *CHRIS_DEPENDS + networks: + - local + worker-periodic: + image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev} + command: celery -A core worker -c 2 -l info -Q periodic + volumes: *CHRIS_VOLUMES + environment: *CHRIS_ENV + user: ${UID}:${GID} + profiles: + - cube + depends_on: *CHRIS_DEPENDS + networks: + - local + celery-scheduler: + image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev} + command: celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler + volumes: *CHRIS_VOLUMES + environment: *CHRIS_ENV + user: ${UID}:${GID} + profiles: + - cube + depends_on: *CHRIS_DEPENDS + networks: + - local + db: + image: docker.io/library/postgres:16 + volumes: + - db:/var/lib/postgresql/data + environment: + - POSTGRES_DB=chris_dev + - POSTGRES_USER=chris + - POSTGRES_PASSWORD=Chris1234 + healthcheck: + test: ["CMD", "pg_isready"] + interval: 2s + timeout: 4s + retries: 3 + start_period: 60s + networks: + local: + aliases: + - chris_dev_db # hard-coded in chris_backend/config/settings/local.py + rabbitmq: + image: docker.io/library/rabbitmq:3 + volumes: + - rabbitmq:/var/lib/rabbitmq + networks: + local: + aliases: + - queue # hard-coded in chris_backend/config/settings/local.py + + pfcon: + image: ${PFCON_IMAGE:-ghcr.io/fnndsc/pfcon:latest} + environment: + COMPUTE_SERVICE_URL: http://pman:5010/api/v1/ + SECRET_KEY: secret + PFCON_USER: pfcon + PFCON_PASSWORD: pfcon1234 + PFCON_INNETWORK: "true" + STORAGE_ENV: filesystem + STOREBASE_MOUNT: /var/local/storeBase + # port is hard-coded in chris_backend/config/settings/local.py + command: gunicorn -b 0.0.0.0:30005 -w 8 -t 120 pfcon.wsgi:application + ports: + - "30005:30005" + volumes: + - chris_files:/var/local/storeBase + user: ${UID}:${GID} + networks: + local: + aliases: + - pfcon.remote # hard-coded in chris_backend/config/settings/local.py + labels: + org.chrisproject.role: "pfcon" + + pman: + image: ${PMAN_IMAGE:-ghcr.io/fnndsc/pman:latest} + environment: + CONTAINER_ENV: docker + CONTAINER_USER: "${UID}:${GID}" + ENABLE_HOME_WORKAROUND: "yes" + JOB_LABELS: "org.chrisproject.miniChRIS=plugininstance" + SECRET_KEY: secret + REMOVE_JOBS: "yes" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - pfcon + ports: + - "5010:5010" + networks: + - local + userns_mode: "host" + + lldap: + image: docker.io/nitnelave/lldap:stable + ports: + - "3890:3890" + - "17170:17170" + volumes: + - "lldap:/data" + environment: + TZ: America/New_York + LLDAP_JWT_SECRET: super_secret_random_string + LLDAP_LDAP_USER_PASS: chris1234 + LLDAP_LDAP_BASE_DN: dc=example,dc=org + networks: + local: + + cube-nonroot-user-volume-fix: + image: docker.io/library/alpine:latest + volumes: + - chris_files:/data + user: root + command: chmod 777 /data + restart: "no" + +volumes: + chris_files: + db: + lldap: + rabbitmq: + +networks: + local: diff --git a/justfile b/justfile new file mode 100644 index 00000000..b533ff31 --- /dev/null +++ b/justfile @@ -0,0 +1,82 @@ +compose_file := 'docker-compose_just.yml' + +# Start the ChRIS backend in development mode, and attach to the live-reloading server. +dev: start attach + +# Start the ChRIS backend in development mode. +start: start-dependencies migrate up + +# Start services (without running database migrations). +up: (docker-compose '--profile=cube up -d') + +# Attach to the chris container. +attach: (docker-compose '--profile=cube attach chris') + +# Open a Python shell. +shell: (run 'python manage.py shell') + +# Open a Bash shell. +bash: (run 'bash') + +# Run chrisomatic, a tool which adds plugins and users to CUBE. +chrisomatic: start + # TODO + +# Run chrisomatic with the contents of chrisomatic/postscript.yml +postscript: start + # TODO + +# Perform database migrations. +migrate: (run 'python manage.py migrate --noinput') + +# Run tests, e.g. `just test pacsfiles` +test *args: + @just run python manage.py test --force-color {{args}} + +# Run all tests. +test-all: test-unit test-integration + +# Run unit tests. +test-unit: (run 'python manage.py test --force-color --exclude-tag integration') + +# Run integration tests. +test-integration: (run 'python manage.py test --force-color --tag integration') + +# Start dependency services. +start-dependencies: (docker-compose 'up -d') + +# Stop services. +down: (docker-compose '--profile=cube --profile=tools down') + +# Stop services and remove all data. +nuke: reap-plugin-instances (docker-compose '--profile=cube --profile=tools down -v --remove-orphans') + +# Remove all plugin instance containers. +reap-plugin-instances: ( + docker-compose 'run --rm pman python -c' ''' + ' + import os + import docker + d = docker.from_env() + filters = {"label": os.getenv("JOB_LABELS")} + containers = d.containers.list(all=True, filters=filters) + for container in containers: + print(f"Removing container: {container.name} ({container.image})", flush=True) + container.remove(force=True) + ' + ''' +) + +# (Re-)build the container image. +build: (docker-compose '--profile=cube build') + +# Pull container images. +pull: (docker-compose 'pull') + +# docker-compose ... run helper function. +run +command: + @just docker-compose --profile=cube run --rm chris {{command}} + +# docker-compose ... helper function. +docker-compose +command: + env UID=$(id -u) GID=$(id -g) docker compose -f '{{ compose_file }}' {{command}} From 8a98d46e84919087914008e15138caa6a9db18a0 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Thu, 29 Aug 2024 00:09:09 -0400 Subject: [PATCH 10/13] Start ancillary services before integration test --- .github/workflows/ci.yml | 2 ++ justfile | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bb91224..4b00143a 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: run: just build - name: Pull other images run: just pull + - name: Start ancillary services + run: just start-ancillary - name: Run unit tests run: just test-unit - name: Run integration tests diff --git a/justfile b/justfile index b533ff31..551e0f53 100644 --- a/justfile +++ b/justfile @@ -4,7 +4,7 @@ compose_file := 'docker-compose_just.yml' dev: start attach # Start the ChRIS backend in development mode. -start: start-dependencies migrate up +start: start-ancillary migrate up # Start services (without running database migrations). up: (docker-compose '--profile=cube up -d') @@ -40,10 +40,10 @@ test-all: test-unit test-integration test-unit: (run 'python manage.py test --force-color --exclude-tag integration') # Run integration tests. -test-integration: (run 'python manage.py test --force-color --tag integration') +test-integration: start-ancillary (run 'python manage.py test --force-color --tag integration') # Start dependency services. -start-dependencies: (docker-compose 'up -d') +start-ancillary: (docker-compose 'up -d') # Stop services. down: (docker-compose '--profile=cube --profile=tools down') From beb6f5fec3afaf47c31f999db152b375d6addf48 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Thu, 29 Aug 2024 11:50:36 -0400 Subject: [PATCH 11/13] Remove obsolete scripts --- docker-compose-dev.sh | 8 -------- docker-compose-down.sh | 13 ------------- 2 files changed, 21 deletions(-) delete mode 100755 docker-compose-dev.sh delete mode 100755 docker-compose-down.sh diff --git a/docker-compose-dev.sh b/docker-compose-dev.sh deleted file mode 100755 index d562a77c..00000000 --- a/docker-compose-dev.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# change to directory where this script lives -cd "$(dirname "$(readlink -f "$0")")" - -set -ex -docker compose -f docker-compose-dev.yml up -d -exec docker compose -f docker-compose-dev.yml run --rm $notty chrisomatic diff --git a/docker-compose-down.sh b/docker-compose-down.sh deleted file mode 100755 index 8b795f82..00000000 --- a/docker-compose-down.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# change to directory where this script lives -cd "$(dirname "$(readlink -f "$0")")" - -set -ex - -# remove all plugin instance jobs -pls=$(docker ps -q -a -f 'label=org.chrisproject.miniChRIS=plugininstance') -[ -z "$pls" ] || docker rm -fv $pls - -# stop and remove everything -docker compose -f docker-compose-dev.yml --profile pacs --profile pflink down -v From 5aac397ac67d04ac1760e34020c3cdaa12317b3d Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Thu, 29 Aug 2024 13:23:11 -0400 Subject: [PATCH 12/13] Implement chrisomatic --- docker-compose_just.yml | 7 +++++-- justfile | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docker-compose_just.yml b/docker-compose_just.yml index 98e2f253..f6aea634 100644 --- a/docker-compose_just.yml +++ b/docker-compose_just.yml @@ -7,8 +7,9 @@ services: profiles: - tools volumes: - - "./chrisomatic/chrisomatic.yml:/chrisomatic.yml" + - "./chrisomatic:/etc/chrisomatic:ro" - "/var/run/docker.sock:/var/run/docker.sock" + working_dir: /etc/chrisomatic userns_mode: host depends_on: - chris @@ -41,7 +42,9 @@ services: cube-nonroot-user-volume-fix: condition: service_completed_successfully networks: - - local + local: + aliases: + - chrisdev.local # hard-coded in chrisomatic/*.yml worker-mains: image: ${CUBE_IMAGE:-localhost/fnndsc/cube:dev} command: celery -A core worker -c 4 -l info -Q main1,main2 diff --git a/justfile b/justfile index 551e0f53..987c636b 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ compose_file := 'docker-compose_just.yml' # Start the ChRIS backend in development mode, and attach to the live-reloading server. -dev: start attach +dev: chrisomatic attach # Start the ChRIS backend in development mode. start: start-ancillary migrate up @@ -19,12 +19,11 @@ shell: (run 'python manage.py shell') bash: (run 'bash') # Run chrisomatic, a tool which adds plugins and users to CUBE. -chrisomatic: start - # TODO +chrisomatic *args: start + @just docker-compose --profile=cube run --rm chrisomatic chrisomatic {{args}} # Run chrisomatic with the contents of chrisomatic/postscript.yml -postscript: start - # TODO +postscript: (chrisomatic 'postscript.yml') # Perform database migrations. migrate: (run 'python manage.py migrate --noinput') From aa0a82fd87c9e30c2ca9a61ba9aefc3baa7ac390 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Thu, 29 Aug 2024 13:25:28 -0400 Subject: [PATCH 13/13] Add tl;dr at top --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a9ec62cb..4721cad4 100755 --- a/README.md +++ b/README.md @@ -7,6 +7,16 @@ _ChRIS_ is an open-source platform for containerized medical compute. https://chrisproject.org/ +## TL;DR + +With [Docker Compose](https://docs.docker.com/compose/) and [just](https://just.systems/) installed, run + +```shell +git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git +cd ChRIS_ultron_backEnd +just +``` + ## Introduction The _ChRIS_ backend, a.k.a. _ChRIS Ultron Backend_ or _**CUBE**_ for short,