diff --git a/apps/cohorter/.gitignore b/apps/cohorter/.gitignore index 2e5dc746..41c0dea9 100644 --- a/apps/cohorter/.gitignore +++ b/apps/cohorter/.gitignore @@ -3,7 +3,9 @@ # ========================= .env .env.* -!.env.example +!/env/ +/env/* +!/env/cohorter.env *.key *.pem *.p12 @@ -50,7 +52,6 @@ __pycache__/ *$py.class .venv/ venv/ -env/ pip-wheel-metadata/ .pytest_cache/ .mypy_cache/ diff --git a/apps/cohorter/NL2DSL/README.md b/apps/cohorter/NL2DSL/README.md index 438ca681..6ca9fd68 100644 --- a/apps/cohorter/NL2DSL/README.md +++ b/apps/cohorter/NL2DSL/README.md @@ -4,7 +4,7 @@ This folder contains the **NL2DSL** service for the Cohorter application. NL2DSL accepts a **natural-language cohort request** and uses an LLM (via **Ollama**) to translate it into a **JSON cohort DSL**. It can optionally call the **MedCAT** service for clinical concept annotation / normalization (depending on your server implementation). -This service is designed to run as part of the full stack (recommended) using the repo-root `docker-compose.yml`. +This service is designed to run as part of the full stack (recommended) using [`docker/docker-compose.yml`](../docker/docker-compose.yml). --- @@ -19,10 +19,10 @@ This service is designed to run as part of the full stack (recommended) using th ## Run with Docker Compose (recommended) -From the **repo root**: +From `apps/cohorter/docker/`, using `env/cohorter.env`: ```bash -docker compose up --build nl2dsl +docker compose --env-file ../env/cohorter.env up --build nl2dsl ``` NL2DSL API will be available at: @@ -110,7 +110,7 @@ node server.js ### Ollama not reachable - If using Docker Compose with included Ollama: confirm `ollama` container is up ```bash - docker compose ps + docker compose --env-file ../env/cohorter.env ps ``` - Check Ollama is responding: ```bash diff --git a/apps/cohorter/README.md b/apps/cohorter/README.md index b46ed4f2..82ffe562 100644 --- a/apps/cohorter/README.md +++ b/apps/cohorter/README.md @@ -18,6 +18,8 @@ A lightweight cohort discovery application that combines: - `WebAPP/` Full application (frontend + backend) providing the UI and orchestration of the workflow. +- `docker/`: Docker Compose configuration for the full stack. + --- ## Quick start (Docker Compose) @@ -27,16 +29,18 @@ A lightweight cohort discovery application that combines: - (Optional) GPU setup if you want Ollama GPU acceleration (depends on your host OS) ### 1) Build and start all services -From this directory: +From `apps/cohorter/`, configure [`env/cohorter.env`](env/cohorter.env), then run +Compose from `docker/`: ```bash -docker compose up --build +cd docker +docker compose --env-file ../env/cohorter.env up --build ``` Or run in background: ```bash -docker compose up --build -d +docker compose --env-file ../env/cohorter.env up --build -d ``` ### 2) Access the app @@ -49,7 +53,7 @@ docker compose up --build -d ## Configuration -### NL2DSL environment variables (via docker-compose.yml) +### NL2DSL environment variables (via docker/docker-compose.yml) NL2DSL uses: - `OLLAMA_URL` (default in compose: `http://ollama:11434/api/generate`) @@ -62,13 +66,13 @@ WebAPP uses: - `NL2DSL_URL` (default: `http://cohorter-nl2dsl:3002`) ### WebAPP random data generation (optional) -The `WebAPP/Dockerfile` supports a build arg `random` to generate random data: +Set the runtime `RANDOM_DATA` variable to generate random data: ```bash -WEBAPP_RANDOM=true docker compose up --build +RANDOM_DATA=true docker compose --env-file ../env/cohorter.env up --build ``` -(If you don’t need random data generation, keep it `false`.) +Set `RANDOM_DATA=false` in `env/cohorter.env` to disable random data generation. --- @@ -86,7 +90,7 @@ Each folder contains its own `Dockerfile` and scripts. ## Notes on models and licensing - MedCAT model packs and any potentially sensitive data **must not** be committed to the repository. -- Ollama models are stored in a Docker named volume by default (`ollama:` in `docker-compose.yml`) so they persist across restarts. +- Ollama models are stored in a Docker named volume by default (`ollama:` in `docker/docker-compose.yml`) so they persist across restarts. --- @@ -94,20 +98,20 @@ Each folder contains its own `Dockerfile` and scripts. ### Rebuild everything cleanly ```bash -docker compose down -docker compose up --build +docker compose --env-file ../env/cohorter.env down +docker compose --env-file ../env/cohorter.env up --build ``` ### Remove Ollama downloaded models (if needed) This deletes the named volume that stores Ollama models: ```bash -docker compose down -v +docker compose --env-file ../env/cohorter.env down -v ``` ### Check logs ```bash -docker compose logs -f +docker compose --env-file ../env/cohorter.env logs -f ``` --- diff --git a/apps/cohorter/WebAPP/README.md b/apps/cohorter/WebAPP/README.md index 9b9e9153..7879a4c6 100644 --- a/apps/cohorter/WebAPP/README.md +++ b/apps/cohorter/WebAPP/README.md @@ -8,7 +8,7 @@ This webapp is a cohort app for users to obtain the number of patients satifying Other runtime dependencies include [ECharts](https://echarts.apache.org/en/index.html) for charts and [popper.js](https://popper.js.org/) for tooltips. -A GitHub Packages token with `read:packages` scope is required to install `@cogstack/frontend-common-react`. Set it in a `.env` file at the `apps/cohorter/` root (see `.env.example`) or export it in your shell: +A GitHub Packages token with `read:packages` scope is required to install `@cogstack/frontend-common-react`. Set it in [`env/cohorter.env`](../env/cohorter.env) for Compose or export it in your shell: ```bash export NPM_TOKEN=ghp_your_token_here @@ -44,7 +44,7 @@ There is a script `gen_random_data.js` in `server/data/` folder to generate the Please make sure to have the six data files ready in the `server/data/` folder before starting the server. To start the server, in the app folder run `cd server && npm install && npm run start`. -The recommended way to run the full stack (webapp + NL2DSL + MedCAT + Ollama) is via `docker-compose` from the `apps/cohorter/` root — see the root-level README and `.env.example` for details. The `NPM_TOKEN` is passed as a BuildKit secret; set it in the `.env` file before building. +The recommended way to run the full stack (webapp + NL2DSL + MedCAT + Ollama) uses [`docker/docker-compose.yml`](../docker/docker-compose.yml) from `apps/cohorter/docker/` — see the app-root README and [`env/cohorter.env`](../env/cohorter.env) for details. The `NPM_TOKEN` is passed as a BuildKit secret. ### Environment variables @@ -92,10 +92,10 @@ In Kubernetes these are set as env vars on the webapp container (via helm `cogst ### Run using Docker with random data -Set `RANDOM_DATA=true` in your `.env` file (or leave it unset — it defaults to `true`), then from the `apps/cohorter/` root: +Set `RANDOM_DATA=true` in `env/cohorter.env` (or leave it unset — it defaults to `true`), then from `apps/cohorter/docker/`: ```bash -docker compose up --build +docker compose --env-file ../env/cohorter.env up --build ``` The webapp will be available at `http://localhost:3000`. diff --git a/apps/cohorter/WebAPP/client-react/README.md b/apps/cohorter/WebAPP/client-react/README.md index 65c19739..b406fcb2 100644 --- a/apps/cohorter/WebAPP/client-react/README.md +++ b/apps/cohorter/WebAPP/client-react/README.md @@ -14,18 +14,14 @@ It keeps the existing Alpine-style template/data model behaviour, while using Re ## Requirements -- Node.js 18+ +- Node.js 20.12+ - npm - A GitHub Packages token with `read:packages` scope (to install `@cogstack/frontend-common-react`) - Cohorter backend server running at `http://localhost:3000` (proxied automatically in dev) ## Environment variables -A single `.env` file at the **`apps/cohorter/` root** (one level up from `WebAPP/`) is shared between Vite and `docker-compose`. Copy `.env.example` there and fill in values: - -```bash -cp ../../.env.example ../../.env -``` +Configure [`apps/cohorter/env/cohorter.env`](../../env/cohorter.env), shared by Vite and Docker Compose. | Variable | Required | Description | |---|---|---| diff --git a/apps/cohorter/WebAPP/client-react/vite.config.js b/apps/cohorter/WebAPP/client-react/vite.config.js index a2c57ea7..a704acc0 100644 --- a/apps/cohorter/WebAPP/client-react/vite.config.js +++ b/apps/cohorter/WebAPP/client-react/vite.config.js @@ -1,17 +1,18 @@ +import { existsSync } from 'node:fs'; +import { loadEnvFile } from 'node:process'; import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; // Express server port (same origin in production; proxied in dev) const API_ORIGIN = 'http://localhost:3000'; -// Point Vite at the apps/cohorter/ root so that it reads the same .env -// as docker-compose, eliminating the need for a separate client-react/.env. -// Both `npm run dev` (Vite) and `docker-compose build` resolve vars from one file. -const ENV_DIR = '../../'; +// Share the named environment file with Compose; image builds can omit it. +const ENV_FILE = new URL('../../env/cohorter.env', import.meta.url); +if (existsSync(ENV_FILE)) loadEnvFile(ENV_FILE); export default defineConfig({ plugins: [react()], - envDir: ENV_DIR, + envDir: false, build: { outDir: 'dist', diff --git a/apps/cohorter/docker-compose.yml b/apps/cohorter/docker/docker-compose.yml similarity index 96% rename from apps/cohorter/docker-compose.yml rename to apps/cohorter/docker/docker-compose.yml index f93dc50c..1139aa04 100644 --- a/apps/cohorter/docker-compose.yml +++ b/apps/cohorter/docker/docker-compose.yml @@ -1,3 +1,5 @@ +name: cohorter + services: ollama: image: ollama/ollama:latest @@ -38,7 +40,7 @@ services: nl2dsl: build: - context: ./NL2DSL + context: ../NL2DSL container_name: cohorter-nl2dsl ports: - "3002:3002" @@ -54,7 +56,7 @@ services: webapp: build: - context: ./WebAPP + context: ../WebAPP secrets: - npm_token args: @@ -84,7 +86,7 @@ services: # Mount your data directory here. It should contain either: # - snomed_terms_data.tar.gz (will be auto-extracted on startup), or # - pre-extracted files: snomed_terms.json (SNOMED term lookup by Concept Unique Identifier) and cui_pt2ch.json (SNOMED CT ontology hierachy map). - - ./WebAPP/server/data:/usr/src/app/server/data + - ../WebAPP/server/data:/usr/src/app/server/data depends_on: - medcat - nl2dsl diff --git a/apps/cohorter/.env.example b/apps/cohorter/env/cohorter.env similarity index 80% rename from apps/cohorter/.env.example rename to apps/cohorter/env/cohorter.env index 9191324f..121bff34 100644 --- a/apps/cohorter/.env.example +++ b/apps/cohorter/env/cohorter.env @@ -1,10 +1,5 @@ -# Single env file for cogstack-cohorter. -# Copy to .env and fill in values before running docker-compose or npm run dev. -# .env is gitignored — never commit it. -# -# This file is read by: -# • docker-compose — variable substitution for build args and runtime env -# • Vite dev server — VITE_* vars picked up via envDir in vite.config.js +# Shared Cohorter configuration for Docker Compose and the Vite dev server. +# Run from docker/: docker compose --env-file ../env/cohorter.env up --build # ── Required ───────────────────────────────────────────────────────────────── @@ -12,7 +7,7 @@ # Used as a BuildKit secret at image build time to install @cogstack/frontend-common-react. # Also needed locally for `npm install` in WebAPP/client-react/ (export NPM_TOKEN in your shell, # or ensure it is set here so docker-compose can pass it through). -NPM_TOKEN=ghp_your_token_here +NPM_TOKEN= # ── OAuth2 proxy paths (Vite build-time, baked into the client bundle) ─────── # Only override if your deployment uses non-standard oauth2-proxy routes. diff --git a/apps/jupyter-hub/.github/workflows/helm-smoke-test.yml b/apps/jupyter-hub/.github/workflows/helm-smoke-test.yml deleted file mode 100644 index 50ded414..00000000 --- a/apps/jupyter-hub/.github/workflows/helm-smoke-test.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: helm-smoke-test - -permissions: - contents: read - -on: - pull_request: - paths: - - "charts/**" - - "env/**" - - "config/**" - - "security/**" - - "scripts/helm_k8s_smoke_test.sh" - - "README.md" - - ".github/workflows/helm-smoke-test.yml" - push: - branches: - - "main" - paths: - - "charts/**" - - "env/**" - - "config/**" - - "security/**" - - "scripts/helm_k8s_smoke_test.sh" - - "README.md" - - ".github/workflows/helm-smoke-test.yml" - workflow_dispatch: - -concurrency: - group: helm-smoke-${{ github.ref }} - cancel-in-progress: true - -jobs: - smoke: - runs-on: ubuntu-22.04 - timeout-minutes: 15 - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - - name: Setup Helm - uses: azure/setup-helm@v5 - - - name: Setup kubectl - uses: azure/setup-kubectl@v5 - - - name: Run Helm and Kubernetes smoke tests - shell: bash - run: | - set -euo pipefail - bash scripts/helm_k8s_smoke_test.sh - - - name: Render manifests for diagnostics - if: failure() - shell: bash - run: | - set -euo pipefail - mkdir -p /tmp/helm-smoke - helm template cogstack-jupyterhub ./charts/cogstack-jupyterhub > /tmp/helm-smoke/render-default.yaml || true - helm template cogstack-jupyterhub ./charts/cogstack-jupyterhub \ - --set envFiles.useBundled=false \ - --set hubFiles.useBundled=false \ - --set securityFiles.useBundled=false \ - --set-file envFiles.jupyter=env/jupyter.env \ - --set-file envFiles.general=env/general.env \ - --set-file hubFiles.jupyterhubConfig=config/jupyterhub_config.py \ - --set-file hubFiles.userlist=config/userlist \ - --set-file hubFiles.teamlist=config/teamlist \ - --set-file securityFiles.cookieSecret=config/jupyterhub_cookie_secret \ - --set-file securityFiles.tlsKey=security/nifi.key \ - --set-file securityFiles.tlsCert=security/nifi.pem \ - > /tmp/helm-smoke/render-set-file.yaml || true - - - name: Upload smoke diagnostics - if: failure() - uses: actions/upload-artifact@v7 - with: - name: helm-smoke-diagnostics - path: /tmp/helm-smoke diff --git a/apps/jupyter-hub/README.md b/apps/jupyter-hub/README.md index 8953ab81..e11c9a49 100644 --- a/apps/jupyter-hub/README.md +++ b/apps/jupyter-hub/README.md @@ -166,7 +166,7 @@ Run local smoke checks for Helm/Kubernetes manifests: bash scripts/helm_k8s_smoke_test.sh ``` -CI also runs this via [`.github/workflows/helm-smoke-test.yml`](./.github/workflows/helm-smoke-test.yml) for changes affecting chart/env/config/security files. +CI chart validation lives in the shared [Helm workflow](../../.github/workflows/build_helm_charts.yml). ## Access and account control diff --git a/apps/nifi/README.md b/apps/nifi/README.md index 0c4418fc..6abf662c 100644 --- a/apps/nifi/README.md +++ b/apps/nifi/README.md @@ -25,7 +25,7 @@ alongside the application. Run from the platform repository root: ```bash -docker build --tag cogstack/cogstack-nifi:local apps/nifi +docker build --tag cogstacksystems/nifi:local apps/nifi ``` `apps/nifi` is the build context. The Dockerfile uses the checked-in dependency @@ -69,12 +69,32 @@ The Kubernetes charts live in and [`deployment/charts/nginx`](../../deployment/charts/nginx/README.md). Their READMEs describe the required environment ConfigMaps, TLS Secrets and storage. -The NiFi build context and resource mounts in `docker/docker-compose.dev.yml` -point to this application directory. The Compose file, Makefile and environment -loader were brought over from the wider CogStack deployment and still reference -supporting configuration, security certificates, services and helper scripts. -Those dependencies need to be migrated or supplied before using the full -deployment helpers. The image build above works independently of them. +NiFi and NGINX share service settings, TLS mounts and volumes in +`docker/docker-compose.base.yml`. Run these commands from `apps/nifi/docker`: + +| Command | Configuration | +| --- | --- | +| `make check-config` | Validate default, dev and prod without starting containers. | +| `make start-nifi-dev-build` | Apply `docker-compose.dev.yml` over the base. Build both images locally, mount local NiFi source, and use `nifi-dev-net`. | +| `source ./export_env_vars.sh && docker compose up -d` | Use `docker-compose.yml` to run published images on a Compose-managed `cogstack-net`. | +| `make start-nifi-prod` | Apply `docker-compose.prod.yml` over the base. Run published images on an existing `cogstack-net`. | + +Set `NIFI_IMAGE` and `NIFI_NGINX_IMAGE` to pin image references for default or +prod. Both publish NiFi through NGINX, and dev also exposes NiFi directly. +Compose uses `docker-compose.override.yml` with the default entry point if you +add one. Append an explicit `-f` for any additional dev or prod overrides. + +Provide `env/general.env`, `env/nifi.env`, NiFi credentials and TLS certificates +before starting the stack. For a published-image deployment, make the mounted +files readable by the image users and set `NIFI_WEB_PROXY_HOST` for the public +host and port. The image build above works independently of these files. + +Certificates live in the shared `deployment/security/certificates/` directory +at the repository root. Put the CA in `root/root-ca.pem` and the NiFi files +(`nifi.pem`, `nifi.key`, `nifi-keystore.jks`, `nifi-truststore.jks`) in `nifi/`. +Both containers mount these files read-only. Certificate contents are ignored by Git. +Supply any ingestion-specific certificate mounts or host overrides in the deployment +that needs them. Mutable configuration, data repositories, processor logs and databases belong in deployment-owned storage. The image health check expects the configured TLS diff --git a/apps/nifi/docker/Makefile b/apps/nifi/docker/Makefile index e8c5cb79..fd173eb4 100644 --- a/apps/nifi/docker/Makefile +++ b/apps/nifi/docker/Makefile @@ -3,24 +3,13 @@ SHELL := /usr/bin/env bash DC_START_CMD := up -d DC_STOP_CMD := stop -DC_DOWN_CMD := down -REMOTE_COMPOSE_FILE ?= services.yml -REMOTE_SSH_KEY ?= -REMOTE_SSH_OPTS ?= -REMOTE_SSH_KEY_ARG = $(if $(strip $(REMOTE_SSH_KEY)),-i $(REMOTE_SSH_KEY),) -SECURITY_DIR ?= ../security -SECURITY_SCRIPTS_DIR ?= $(SECURITY_DIR)/scripts -SECURITY_CERTIFICATES_DIR ?= $(SECURITY_DIR)/certificates -SECURITY_ENV_DIR ?= $(SECURITY_DIR)/env -OPENSEARCH_CERT_NAMES ?= -COGSTACK_CONFIG_DIR ?= -export COGSTACK_CONFIG_DIR +COMPOSE_DEV := docker compose -f docker-compose.base.yml -f docker-compose.dev.yml +COMPOSE_PROD := docker compose -f docker-compose.base.yml -f docker-compose.prod.yml define WITH_ENV source ./export_env_vars.sh || exit $$?; endef -# list all make targets in this file help: ## List available targets with descriptions @echo "Available targets:" @awk '\ @@ -28,11 +17,8 @@ help: ## List available targets with descriptions if (target ~ /^start-/) return "Start a service or service group"; \ if (target ~ /^stop-/) return "Stop a service or service group"; \ if (target ~ /^delete-/) return "Delete related containers/images/volumes"; \ - if (target ~ /^git-/) return "Run a git helper script"; \ if (target == "load-env") return "Load variables from export_env_vars.sh"; \ if (target == "show-env") return "Print current environment variables"; \ - if (target == "down-all") return "Stop all services from services.yml"; \ - if (target == "cleanup") return "Stop all services and remove volumes"; \ return "(no description)"; \ } \ /^[a-zA-Z0-9][a-zA-Z0-9_-]*:/ { \ @@ -57,219 +43,24 @@ help: ## List available targets with descriptions } \ ' $(MAKEFILE_LIST) | sort | awk -F '\t' '{printf " %-28s %s\n", $$1, $$2}' -.PHONY: help - -# utility commands - -git-freeze-security: ## Apply restricted git settings for safer shell operations - @../scripts/git_freeze_security.sh - -git-unfreeze-security: ## Revert restricted git settings - @../scripts/git_unfreeze_security.sh - -git-init-submodules: ## Initialize submodules at the commits recorded by this checkout - @../scripts/git_init_submodules_in_repo.sh - -git-update-submodules: ## Explicitly upgrade direct submodules for review (never stages or commits) - @../scripts/git_update_submodules_in_repo.sh - -.PHONY: git-init-submodules git-update-submodules - load-env: ## Load variables from export_env_vars.sh in a subshell $(WITH_ENV) echo "Environment variables loaded." show-env: ## Print sorted environment variables after loading export_env_vars.sh ${WITH_ENV} >/dev/null 2>&1; printenv | sort -init-security-root-ca: ## Generate the shared root CA only when no CA material exists - @set -euo pipefail; \ - $(WITH_ENV) \ - source "$${COGSTACK_CERTIFICATES_GENERAL_ENV_FILE}"; \ - root_dir="$(SECURITY_CERTIFICATES_DIR)/root"; \ - if [[ -f "$$root_dir/$${ROOT_CERTIFICATE_NAME}.key" \ - && -f "$$root_dir/$${ROOT_CERTIFICATE_NAME}.pem" \ - && -f "$$root_dir/$${ROOT_CERTIFICATE_NAME}.p12" \ - && -f "$$root_dir/$${ROOT_CERTIFICATE_NAME}-keystore.jks" \ - && -f "$$root_dir/$${ROOT_CERTIFICATE_NAME}-truststore.jks" ]]; then \ - echo "Root CA certificates already exist; leaving them unchanged."; \ - elif [[ -d "$$root_dir" && -n "$$(find "$$root_dir" -mindepth 1 -maxdepth 1 -print -quit)" ]]; then \ - echo "ERROR: $$root_dir contains an incomplete root CA set." >&2; \ - echo "Preserve and repair or explicitly replace that CA before rerunning this target." >&2; \ - exit 1; \ - else \ - echo "Generating the shared root CA certificates..."; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && ./create_root_ca_cert.sh); \ - fi - -init-security-nifi: init-security-opensearch init-security-postgresql ## Prepare NiFi certificates and its search/database certificate inputs - @set -euo pipefail; \ - nifi_dir="$(SECURITY_CERTIFICATES_DIR)/nifi"; \ - if [[ -f "$$nifi_dir/nifi.key" \ - && -f "$$nifi_dir/nifi.pem" \ - && -f "$$nifi_dir/nifi.p12" \ - && -f "$$nifi_dir/nifi-keystore.jks" \ - && -f "$$nifi_dir/nifi-truststore.jks" ]]; then \ - echo "NiFi certificates already exist; leaving them unchanged."; \ - else \ - echo "Generating NiFi certificates..."; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && ./create_nifi_certs.sh); \ - fi - -init-security-gitea: init-security-root-ca ## Generate a dedicated Gitea leaf certificate when it is missing - @set -euo pipefail; \ - gitea_dir="$(SECURITY_CERTIFICATES_DIR)/gitea"; \ - if [[ -f "$$gitea_dir/gitea.key" \ - && -f "$$gitea_dir/gitea.pem" \ - && -f "$$gitea_dir/gitea.crt" ]]; then \ - echo "Gitea leaf certificate already exists; leaving it unchanged."; \ - else \ - echo "Generating Gitea leaf certificate..."; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && bash ./create_gitea_certs.sh); \ - fi - -init-security-opensearch: init-security-root-ca ## Generate OpenSearch node, client, and admin certificates when missing - @set -euo pipefail; \ - $(WITH_ENV) \ - source "$${COGSTACK_CERTIFICATES_ELASTICSEARCH_ENV_FILE}"; \ - if [[ -n "$(strip $(OPENSEARCH_CERT_NAMES))" ]]; then \ - read -r -a node_names <<< "$(strip $(OPENSEARCH_CERT_NAMES))"; \ - else \ - node_names=("$$ES_INSTANCE_NAME_1" "$$ES_INSTANCE_NAME_2" "$$ES_INSTANCE_NAME_3"); \ - fi; \ - opensearch_dir="$(SECURITY_CERTIFICATES_DIR)/elastic/opensearch"; \ - node_certificates_missing=0; \ - for node_name in "$${node_names[@]}"; do \ - node_dir="$$opensearch_dir/elasticsearch/$$node_name"; \ - for suffix in .crt .key .p12 -keystore.jks -truststore.key; do \ - if [[ ! -f "$$node_dir/$$node_name$$suffix" ]]; then \ - node_certificates_missing=1; \ - break 2; \ - fi; \ - done; \ - done; \ - if [[ ! -f "$$opensearch_dir/elastic-stack-ca.crt.pem" ]]; then \ - node_certificates_missing=1; \ - fi; \ - if (( node_certificates_missing )); then \ - echo "Generating OpenSearch node certificates for: $${node_names[*]}"; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && ./create_opensearch_node_cert.sh "$${node_names[@]}"); \ - else \ - echo "OpenSearch node certificates already exist; leaving them unchanged."; \ - fi; \ - if [[ -f "$$opensearch_dir/admin.crt" \ - && -f "$$opensearch_dir/admin.key.pem" \ - && -f "$$opensearch_dir/$${ES_CLIENT_CERT_NAME}.pem" \ - && -f "$$opensearch_dir/$${ES_CLIENT_CERT_NAME}.key" ]]; then \ - echo "OpenSearch client and admin certificates already exist; leaving them unchanged."; \ - else \ - echo "Generating OpenSearch client and admin certificates..."; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && ./create_opensearch_client_admin_certs.sh); \ - fi - -init-security-elasticsearch: ## Generate native Elasticsearch certificates when the output directory is absent - @set -euo pipefail; \ - $(WITH_ENV) \ - source "$${COGSTACK_CERTIFICATES_ELASTICSEARCH_ENV_FILE}"; \ - elasticsearch_dir="$(SECURITY_CERTIFICATES_DIR)/elastic/elasticsearch"; \ - certificate_set_complete=1; \ - for required_file in \ - "elastic-stack-ca.crt.pem" \ - "elastic-stack-ca.p12" \ - "elasticsearch/$${ES_INSTANCE_NAME_1}/$${ES_INSTANCE_NAME_1}.crt" \ - "elasticsearch/$${ES_INSTANCE_NAME_1}/$${ES_INSTANCE_NAME_1}.key" \ - "elasticsearch/$${ES_INSTANCE_NAME_2}/$${ES_INSTANCE_NAME_2}.crt" \ - "elasticsearch/$${ES_INSTANCE_NAME_2}/$${ES_INSTANCE_NAME_2}.key" \ - "elasticsearch/$${ES_INSTANCE_NAME_3}/$${ES_INSTANCE_NAME_3}.crt" \ - "elasticsearch/$${ES_INSTANCE_NAME_3}/$${ES_INSTANCE_NAME_3}.key"; do \ - if [[ ! -f "$$elasticsearch_dir/$$required_file" ]]; then \ - certificate_set_complete=0; \ - break; \ - fi; \ - done; \ - if (( certificate_set_complete )); then \ - echo "Native Elasticsearch certificates already exist; leaving them unchanged."; \ - elif [[ -e "$$elasticsearch_dir" ]]; then \ - echo "ERROR: $$elasticsearch_dir exists but contains an incomplete certificate set." >&2; \ - echo "Move or remove that directory after preserving anything needed, then rerun this target." >&2; \ - exit 1; \ - else \ - echo "Generating native Elasticsearch certificates with Docker..."; \ - (cd "$(SECURITY_SCRIPTS_DIR)" && ./create_es_native_certs.sh); \ - fi - -init-security-search: ## Generate certificates for ELASTICSEARCH_VERSION from elasticsearch.env - @set -euo pipefail; \ - $(WITH_ENV) \ - source "$${COGSTACK_ELASTICSEARCH_ENV_FILE}"; \ - case "$${ELASTICSEARCH_VERSION}" in \ - opensearch|elasticsearch) \ - $(MAKE) --no-print-directory "init-security-$${ELASTICSEARCH_VERSION}" \ - ;; \ - *) \ - echo "ERROR: unsupported ELASTICSEARCH_VERSION '$${ELASTICSEARCH_VERSION}'." >&2; \ - exit 1 \ - ;; \ - esac - -init-security-postgresql: init-security-root-ca ## Generate missing PostgreSQL TLS bundles, preserving supplied certificates - @$(WITH_ENV) SECURITY_CERTIFICATES_DIR="$(SECURITY_CERTIFICATES_DIR)" bash "$(SECURITY_SCRIPTS_DIR)/create_postgres_certs.sh" - -init-security: ## Generate missing NiFi, PostgreSQL, Gitea, and selected search-backend certificates - @$(MAKE) --no-print-directory init-security-nifi - @$(MAKE) --no-print-directory init-security-gitea - @$(MAKE) --no-print-directory init-security-search - -.PHONY: init-security init-security-root-ca init-security-nifi init-security-postgresql init-security-gitea init-security-opensearch init-security-elasticsearch init-security-search - -remote-deploy-service: ## Deploy one or more services to a remote machine via SSH + docker compose -remote-deploy-service: _check-remote-params - @ssh $(REMOTE_SSH_KEY_ARG) $(REMOTE_SSH_OPTS) "$(REMOTE_HOST)" 'cd "$(REMOTE_REPO_DIR)/deploy" && set -a && source ./export_env_vars.sh && docker compose -f "$(REMOTE_COMPOSE_FILE)" up -d $(REMOTE_SERVICES)' - -remote-stop-service: ## Stop one or more services on a remote machine via SSH + docker compose -remote-stop-service: _check-remote-params - @ssh $(REMOTE_SSH_KEY_ARG) $(REMOTE_SSH_OPTS) "$(REMOTE_HOST)" 'cd "$(REMOTE_REPO_DIR)/deploy" && set -a && source ./export_env_vars.sh && docker compose -f "$(REMOTE_COMPOSE_FILE)" stop $(REMOTE_SERVICES)' - -remote-delete-service: ## Delete one or more remote service containers via SSH + docker compose rm -remote-delete-service: _check-remote-params - @ssh $(REMOTE_SSH_KEY_ARG) $(REMOTE_SSH_OPTS) "$(REMOTE_HOST)" 'cd "$(REMOTE_REPO_DIR)/deploy" && set -a && source ./export_env_vars.sh && docker compose -f "$(REMOTE_COMPOSE_FILE)" rm -f -s $(REMOTE_SERVICES)' - -_check-remote-params: - @if [ -z "$(REMOTE_HOST)" ]; then \ - echo "REMOTE_HOST is required (example: REMOTE_HOST=user@machine)"; \ - exit 1; \ - fi - @if [ -z "$(REMOTE_REPO_DIR)" ]; then \ - echo "REMOTE_REPO_DIR is required (example: REMOTE_REPO_DIR=/opt/cogstack_nifi)"; \ - exit 1; \ - fi - @if [ -z "$(REMOTE_SERVICES)" ]; then \ - echo "REMOTE_SERVICES is required (example: REMOTE_SERVICES='nifi nifi-nginx')"; \ - exit 1; \ - fi +check-config: ## Validate the default, dev and prod Compose configurations + @$(WITH_ENV) docker compose config --quiet && \ + $(COMPOSE_DEV) config --quiet && $(COMPOSE_PROD) config --quiet -.PHONY: remote-deploy-service remote-stop-service remote-delete-service _check-remote-params - -check-nifi-resources: ## Validate NiFi heap sizes against the container memory limit - @$(WITH_ENV) python3 ../scripts/tests/check_nifi_resources.py +start-nifi-dev: ## Start NiFi and NGINX with local builds + $(WITH_ENV) $(COMPOSE_DEV) $(DC_START_CMD) nifi nifi-nginx -check-opensearch-settings: ## Validate search credentials, encryption keys, and image versions - @$(WITH_ENV) python3 ../scripts/tests/check_opensearch_settings.py +start-nifi-dev-build: ## Build and start NiFi dev services + $(WITH_ENV) $(COMPOSE_DEV) up -d --build nifi nifi-nginx -check-config: check-nifi-resources check-opensearch-settings ## Validate resolved settings and both core Compose files - @$(WITH_ENV) docker compose --profile "*" -f services.yml config --quiet && docker compose --profile "*" -f docker-compose.dev.yml config --quiet - -.PHONY: check-nifi-resources check-opensearch-settings check-config - -# start services - -start-nifi: check-nifi-resources ## Start NiFi and NiFi nginx (services.yml) - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) nifi nifi-nginx - -start-nifi-dev: check-nifi-resources ## Start NiFi and NiFi nginx (docker-compose.dev.yml) - $(WITH_ENV) docker compose -f docker-compose.dev.yml $(DC_START_CMD) nifi nifi-nginx - -start-nifi-dev-build: check-nifi-resources ## Build and start NiFi dev services - $(WITH_ENV) docker compose -f docker-compose.dev.yml up -d --build nifi nifi-nginx +start-nifi-prod: ## Start the published NiFi and NGINX images on cogstack-net + $(WITH_ENV) $(COMPOSE_PROD) $(DC_START_CMD) build-nifi-image: ## Build the local NiFi image without starting services $(WITH_ENV) docker build \ @@ -277,307 +68,32 @@ build-nifi-image: ## Build the local NiFi image without starting services --build-arg NIFI_BASE_IMAGE="$${NIFI_BASE_IMAGE}" \ --build-arg NIFI_UID="$${COGSTACK_LOCAL_UID:-1000}" \ --build-arg NIFI_GID="$${COGSTACK_LOCAL_GID:-1000}" \ - --tag "$${NIFI_LOCAL_DOCKER_IMAGE:-cogstack/cogstack-nifi:local}" \ + --tag "$${NIFI_LOCAL_DOCKER_IMAGE:-cogstacksystems/nifi:local}" \ --file ../Dockerfile \ .. -start-elastic: check-opensearch-settings ## Start elasticsearch-1, elasticsearch-2 and kibana - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) elasticsearch-1 elasticsearch-2 kibana - -start-elastic-cluster: check-opensearch-settings ## Start full 3-node Elasticsearch cluster - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) elasticsearch-1 elasticsearch-2 elasticsearch-3 - -start-elastic-1: check-opensearch-settings - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) elasticsearch-1 - -start-elastic-2: check-opensearch-settings - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) elasticsearch-2 - -start-elastic-3: check-opensearch-settings - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) elasticsearch-3 - -start-metricbeat-1: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) metricbeat-1 - -start-metricbeat-2: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) metricbeat-2 - -start-metricbeat-3: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) metricbeat-3 - -start-filebeat-1: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) filebeat-1 - -start-filebeat-2: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) filebeat-2 - -start-filebeat-3: - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) filebeat-3 - -start-kibana: check-opensearch-settings ## Start Kibana or OpenSearch Dashboards - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) kibana - -start-ollama: ## Start the Ollama inference service - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) ollama - -start-ollama-openai-proxy: ## Build and start the OpenSearch-to-Ollama compatibility proxy - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) --build ollama-openai-proxy - -pull-ollama-model: start-ollama ## Pull the model configured by OLLAMA_MODEL - $(WITH_ENV) docker compose -f services.yml exec -T ollama ollama pull "$${OLLAMA_MODEL}" - -setup-ollama: pull-ollama-model ## Start Ollama and pull its configured model - -opensearch-ai-init: ## Create or update OpenSearch AI connectors and agents using OPENSEARCH_AI_PROVIDER - $(WITH_ENV) \ - case "$${OPENSEARCH_AI_PROVIDER:-ollama}" in \ - ollama) docker compose -f services.yml $(DC_START_CMD) --build ollama-openai-proxy ;; \ - sglang) ;; \ - *) echo "Unsupported OPENSEARCH_AI_PROVIDER: $${OPENSEARCH_AI_PROVIDER}" >&2; exit 1 ;; \ - esac && ../scripts/opensearch-ai-init.sh - -opensearch-ai-init-sglang: ## Connect all OpenSearch AI features to the locally hosted SGLang server - $(WITH_ENV) OPENSEARCH_AI_PROVIDER=sglang ../scripts/opensearch-ai-init.sh - -start-openwebui: ## Start Open WebUI and its Ollama dependency - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) open-webui - -restart-openwebui: ## Restart the Open WebUI container - $(WITH_ENV) docker compose -f services.yml restart open-webui - -status-openwebui: ## Show Open WebUI and Ollama container status - $(WITH_ENV) docker compose -f services.yml ps open-webui ollama - -logs-openwebui: ## Follow the Open WebUI logs - $(WITH_ENV) docker compose -f services.yml logs --tail=100 -f open-webui - -start-samples: ## Start the sample database service - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) samples-db && \ - docker compose -f services.yml exec -T -e PGHOST=samples-db samples-db /docker-entrypoint-initdb.d/access/configure.sh - -start-clickhouse: ## Start the ClickHouse ingestion database - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) clickhouse - -status-clickhouse: ## Show ClickHouse container status - $(WITH_ENV) docker compose -f services.yml ps clickhouse - -logs-clickhouse: ## Follow ClickHouse logs - $(WITH_ENV) docker compose -f services.yml logs --tail=100 -f clickhouse - -start-jupyter: - $(WITH_ENV) docker compose -f ../../jupyter-hub/docker/docker-compose.base.yml -f ../../jupyter-hub/docker/docker-compose.prod.yml $(DC_START_CMD) cogstack-jupyter-hub - -start-medcat-service: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml $(DC_START_CMD) nlp-medcat-service-production - -start-medcat-service-deid: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml $(DC_START_CMD) nlp-medcat-service-production-deid +stop-nifi-dev: ## Stop the NiFi dev services + $(WITH_ENV) $(COMPOSE_DEV) $(DC_STOP_CMD) nifi nifi-nginx -start-medcat-trainer: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml $(DC_START_CMD) medcattrainer nginx solr +stop-nifi-prod: ## Stop the NiFi prod services + $(WITH_ENV) $(COMPOSE_PROD) $(DC_STOP_CMD) -start-production-db: - $(WITH_ENV) docker compose -f services.yml ${DC_START_CMD} cogstack-databank-db && \ - docker compose -f services.yml exec -T -e PGHOST=cogstack-databank-db cogstack-databank-db /docker-entrypoint-initdb.d/access/configure.sh +delete-nifi: delete-nifi-dev-containers ## Stop and remove the NiFi and NGINX containers -start-production-db-mssql: ## Start SQL Server and wait for its schema initialization job - $(WITH_ENV) docker compose -f services.yml $(DC_START_CMD) cogstack-databank-db-mssql && \ - docker compose -f services.yml run --rm --no-deps cogstack-databank-db-mssql-init +delete-nifi-dev-containers: ## Remove the NiFi dev containers + $(WITH_ENV) $(COMPOSE_DEV) rm -f -s nifi nifi-nginx -start-ocr-services: - $(WITH_ENV) docker compose -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.base.yml -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.prod.yml $(DC_START_CMD) ocr-service ocr-service-text-only +delete-nifi-dev-volumes: delete-nifi-dev-containers ## Remove the NiFi and NGINX containers and delete NiFi dev volume data + @$(WITH_ENV) volumes="$$($(COMPOSE_DEV) config --format json | \ + jq -r '.volumes[]? | select(.external != true) | .name')" || exit $$?; \ + if [ -n "$$volumes" ]; then docker volume rm -f $$volumes; fi -start-git-ea: - $(WITH_ENV) docker compose -f services.yml ${DC_START_CMD} gitea - -start-data-infra: start-nifi start-elastic start-samples ## Start core data infrastructure - -start-all: start-data-infra start-medcat-service start-ocr-services ## Start all major services - -.PHONY: start-kibana start-all start-data-infra start-nifi start-nifi-dev start-nifi-dev-build build-nifi-image start-elastic start-ollama start-ollama-openai-proxy pull-ollama-model setup-ollama opensearch-ai-init opensearch-ai-init-sglang start-openwebui restart-openwebui status-openwebui logs-openwebui start-samples start-clickhouse status-clickhouse logs-clickhouse start-jupyter - - -# stop services -# -stop-nifi: ## Stop NiFi and NiFi nginx (services.yml) - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) nifi nifi-nginx - -stop-nifi-dev: ## Stop NiFi and NiFi nginx (docker-compose.dev.yml) - $(WITH_ENV) docker compose -f docker-compose.dev.yml $(DC_STOP_CMD) nifi nifi-nginx - -delete-nifi: delete-nifi-containers ## Delete NiFi containers only - -delete-nifi-containers: ## Remove NiFi containers from services.yml - $(WITH_ENV) docker compose -f services.yml rm -f -s nifi nifi-nginx - -delete-nifi-dev-containers: ## Remove NiFi containers from docker-compose.dev.yml - $(WITH_ENV) docker compose -f docker-compose.dev.yml rm -f -s nifi nifi-nginx - -delete-nifi-images: ## Delete NiFi images referenced in services.yml - $(WITH_ENV) images="$$(docker compose -f services.yml config --images nifi nifi-nginx | sort -u)"; \ - if [ -n "$$images" ]; then \ - docker image rm -f $$images; \ - else \ - echo "No NiFi images found in services.yml"; \ - fi - -delete-nifi-dev-images: ## Delete NiFi images referenced in docker-compose.dev.yml - $(WITH_ENV) images="$$(docker compose -f docker-compose.dev.yml config --images nifi nifi-nginx | sort -u)"; \ +delete-nifi-dev-images: ## Delete the NiFi dev images + $(WITH_ENV) images="$$($(COMPOSE_DEV) config --images nifi nifi-nginx | sort -u)" || exit $$?; \ if [ -n "$$images" ]; then \ docker image rm -f $$images; \ else \ - echo "No NiFi images found in docker-compose.dev.yml"; \ + echo "No NiFi dev images found."; \ fi -delete-nifi-volumes: ## Delete NiFi volumes - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) -v nifi nifi-nginx - -delete-elastic: ## Remove Elasticsearch and Kibana containers - $(WITH_ENV) docker compose -f services.yml rm -f -s elasticsearch-1 elasticsearch-2 elasticsearch-3 kibana - -delete-elastic-volumes: ## Delete Elasticsearch and Kibana volumes - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) -v elasticsearch-1 elasticsearch-2 elasticsearch-3 kibana - -delete-ollama: ## Remove the Ollama container but preserve downloaded models - $(WITH_ENV) docker compose -f services.yml rm -f -s ollama - -delete-ollama-openai-proxy: ## Remove the OpenSearch-to-Ollama compatibility proxy container - $(WITH_ENV) docker compose -f services.yml rm -f -s ollama-openai-proxy - -delete-ollama-proxy: delete-ollama-openai-proxy ## Alias for delete-ollama-openai-proxy - -delete-openwebui: ## Remove the Open WebUI container but preserve its data - $(WITH_ENV) docker compose -f services.yml rm -f -s open-webui - -delete-databank: - $(WITH_ENV) docker compose -f services.yml rm -f -s cogstack-databank-db cogstack-databank-db-mssql-init cogstack-databank-db-mssql - -delete-databank-volumes: - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) -v cogstack-databank-db cogstack-databank-db-mssql - -delete-samples-db: - $(WITH_ENV) docker compose -f services.yml rm -f -s samples-db - -delete-samples-db-volumes: - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) -v samples-db - -delete-clickhouse: ## Remove the ClickHouse container but preserve its data - $(WITH_ENV) docker compose -f services.yml rm -f -s clickhouse - -delete-medcat-trainer: ## Remove MedCAT Trainer containers - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml rm -f -s medcattrainer nginx solr - -delete-medcat-trainer-volumes: ## Delete MedCAT Trainer volumes - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml $(DC_DOWN_CMD) -v medcattrainer nginx solr - -delete-jupyter: ## Remove Jupyter container - $(WITH_ENV) docker compose -f ../../jupyter-hub/docker/docker-compose.base.yml -f ../../jupyter-hub/docker/docker-compose.prod.yml rm -f -s cogstack-jupyter-hub - -delete-medcat-service: ## Remove MedCAT service container - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml rm -f -s nlp-medcat-service-production - -delete-medcat-service-deid: ## Remove MedCAT service (deid) container - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml rm -f -s nlp-medcat-service-production-deid - -delete-ocr-services: ## Remove OCR service containers - $(WITH_ENV) docker compose -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.base.yml -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.prod.yml rm -f -s ocr-service ocr-service-text-only - -make-delete-jupyter: delete-jupyter ## Alias for delete-jupyter - -make-delete-medcat-service: delete-medcat-service ## Alias for delete-medcat-service - -make-delete-medcat-service-deid: delete-medcat-service-deid ## Alias for delete-medcat-service-deid - -make-delete-ocr-services: delete-ocr-services ## Alias for delete-ocr-services - -stop-elastic: ## Stop elasticsearch-1, elasticsearch-2 and kibana - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) elasticsearch-1 elasticsearch-2 kibana - -stop-elastic-cluster: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) elasticsearch-1 elasticsearch-2 - -stop-elastic-1: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) elasticsearch-1 - -stop-elastic-2: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) elasticsearch-2 - -stop-elastic-3: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) elasticsearch-3 - -stop-metricbeat-1: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) metricbeat-1 - -stop-metricbeat-2: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) metricbeat-2 - -stop-filebeat-1: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) filebeat-1 - -stop-filebeat-2: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) filebeat-2 - -stop-filebeat-3: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) filebeat-3 - -stop-kibana: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) kibana - -stop-ollama: ## Stop the Ollama inference service - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) ollama - -stop-openwebui: ## Stop the Open WebUI service - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) open-webui - -stop-samples: ## Stop the sample database service - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) samples-db - -stop-clickhouse: ## Stop the ClickHouse ingestion database - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) clickhouse - -stop-jupyter: - $(WITH_ENV) docker compose -f ../../jupyter-hub/docker/docker-compose.base.yml -f ../../jupyter-hub/docker/docker-compose.yml $(DC_STOP_CMD) cogstack-jupyter-hub - -stop-medcat-trainer: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-trainer/docker-compose-prod.yml $(DC_STOP_CMD) medcattrainer nginx solr - -stop-medcat-service: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml $(DC_STOP_CMD) nlp-medcat-service-production - -stop-medcat-service-deid: - $(WITH_ENV) docker compose -f ../services/cogstack-nlp/medcat-service/docker/docker-compose.yml $(DC_STOP_CMD) nlp-medcat-service-production-deid - -stop-git-ea: - $(WITH_ENV) docker compose -f services.yml ${DC_STOP_CMD} gitea - -stop-ocr-services: - $(WITH_ENV) docker compose -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.base.yml -f ../services/cogstack-platform/apps/ocr-service/docker/docker-compose.prod.yml $(DC_STOP_CMD) ocr-service ocr-service-text-only - -stop-production-db: - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) cogstack-databank-db - -stop-production-db-mssql: ## Stop the SQL Server initializer and server without removing data - $(WITH_ENV) docker compose -f services.yml $(DC_STOP_CMD) cogstack-databank-db-mssql-init cogstack-databank-db-mssql - -.PHONY: start-production-db-mssql stop-production-db-mssql - -stop-data-infra: stop-nifi stop-elastic stop-samples ## Stop core data infrastructure - -stop-all: stop-data-infra stop-jupyter stop-medcat-service stop-ocr-services ## Stop all major services - -.PHONY: stop-data-infra stop-nifi stop-nifi-dev delete-nifi delete-nifi-containers delete-nifi-dev-containers delete-nifi-images delete-nifi-dev-images delete-nifi-volumes delete-elastic delete-elastic-volumes delete-ollama delete-ollama-openai-proxy delete-ollama-proxy delete-openwebui delete-databank delete-databank-volumes delete-samples-db delete-samples-db-volumes delete-clickhouse delete-medcat-trainer delete-medcat-trainer-volumes delete-jupyter delete-medcat-service delete-medcat-service-deid delete-ocr-services make-delete-jupyter make-delete-medcat-service make-delete-medcat-service-deid make-delete-ocr-services stop-elastic stop-ollama stop-openwebui stop-samples stop-clickhouse stop-jupyter - - -# cleanup -# -down-all: ## Run docker compose down for services.yml - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) - -# deletes volumes associated with containers -cleanup: ## Run docker compose down -v for services.yml - $(WITH_ENV) docker compose -f services.yml $(DC_DOWN_CMD) -v - -.PHONY: down-all cleanup - -# Expose Kubernetes commands when their deployment helpers are present. --include kubernetes/Makefile +.PHONY: help load-env show-env check-config start-nifi-dev start-nifi-dev-build start-nifi-prod build-nifi-image stop-nifi-dev stop-nifi-prod delete-nifi delete-nifi-dev-containers delete-nifi-dev-volumes delete-nifi-dev-images diff --git a/apps/nifi/docker/docker-compose.base.yml b/apps/nifi/docker/docker-compose.base.yml new file mode 100644 index 00000000..163ec7c5 --- /dev/null +++ b/apps/nifi/docker/docker-compose.base.yml @@ -0,0 +1,172 @@ +#---------------------------------------------------------------------------# +# Common snippets / anchors # +#---------------------------------------------------------------------------# + +x-nifi-logging-common: &nifi-logging-common + driver: "json-file" + options: + max-size: ${NIFI_DOCKER_LOG_SIZE_PER_FILE:-250m} + max-file: ${NIFI_DOCKER_LOG_NUM_FILES:-10} + +x-env-files: + all: &all-env + - "${COGSTACK_GENERAL_ENV_FILE:-../env/general.env}" + - "${COGSTACK_NIFI_ENV_FILE:-../env/nifi.env}" + +x-env: + nifi: &nifi-env + # Apache's native startup settings; existing deployment env names remain supported. + AUTH: ${AUTH:-tls} + NIFI_SECURITY_USER_AUTHORIZER: ${NIFI_SECURITY_USER_AUTHORIZER:-single-user-authorizer} + NIFI_SECURITY_USER_LOGIN_IDENTITY_PROVIDER: ${NIFI_SECURITY_USER_LOGIN_IDENTITY_PROVIDER:-single-user-provider} + SINGLE_USER_CREDENTIALS_USERNAME: ${SINGLE_USER_CREDENTIALS_USERNAME:-${NIFI_SINGLE_USER_CREDENTIALS_USERNAME}} + SINGLE_USER_CREDENTIALS_PASSWORD: ${SINGLE_USER_CREDENTIALS_PASSWORD:-${NIFI_SINGLE_USER_CREDENTIALS_PASSWORD}} + KEYSTORE_PATH: ${KEYSTORE_PATH:-${NIFI_KEYSTORE_PATH}} + KEYSTORE_TYPE: ${KEYSTORE_TYPE:-${NIFI_KEYSTORE_TYPE}} + KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD:-${NIFI_KEYSTORE_PASSWORD}} + TRUSTSTORE_PATH: ${TRUSTSTORE_PATH:-${NIFI_TRUSTSTORE_PATH}} + TRUSTSTORE_TYPE: ${TRUSTSTORE_TYPE:-${NIFI_TRUSTSTORE_TYPE}} + TRUSTSTORE_PASSWORD: ${TRUSTSTORE_PASSWORD:-${NIFI_TRUSTSTORE_PASSWORD}} + NIFI_WEB_HTTPS_PORT: ${NIFI_WEB_HTTPS_PORT:-${NIFI_INTERNAL_PORT:-8443}} + NIFI_REMOTE_INPUT_SOCKET_PORT: ${NIFI_REMOTE_INPUT_SOCKET_PORT:-${NIFI_INPUT_SOCKET_PORT:-10000}} + PYTHONPATH: ${NIFI_PYTHONPATH:-/opt/nifi/nifi-current/python/framework} + JVM_OPTS: ${NIFI_JVM_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+ParallelRefProcEnabled -Djava.security.egd=file:/dev/./urandom} + + nifi-nginx: &nifi-nginx-env + NIFI_INTERNAL_PORT_NGINX: ${NIFI_INTERNAL_PORT_NGINX:-8443} + NIFI_WEB_PROXY_PORT: ${NIFI_WEB_PROXY_PORT:-8443} + NIFI_INTERNAL_PORT: ${NIFI_INTERNAL_PORT:-8443} + NIFI_UPSTREAM_HOST: ${NIFI_UPSTREAM_HOST:-nifi} + NIFI_UPSTREAM_PORT: ${NIFI_UPSTREAM_PORT:-${NIFI_INTERNAL_PORT:-8443}} + NIFI_UPSTREAM_TLS_NAME: ${NIFI_UPSTREAM_TLS_NAME:-nifi} + +x-mounts: + nifi: &nifi-volumes + # Security certificates + - ../../../deployment/security/certificates/nifi:/security/certificates/nifi:ro + - ../../../deployment/security/certificates/root/root-ca.pem:/security/certificates/root/root-ca.pem:ro + # Apache startup configures image defaults in this persistent, writable directory. + - nifi-vol-conf:/opt/nifi/nifi-current/conf + + # Ingest data directory + - ${NIFI_DATA_PATH:-../data/}:/data/:rw + + # NiFi repositories/state + - nifi-vol-logs:/opt/nifi/nifi-current/logs + - nifi-vol-provenance:/opt/nifi/nifi-current/provenance_repository + - nifi-vol-database:/opt/nifi/nifi-current/database_repository + - nifi-vol-flowfiles:/opt/nifi/nifi-current/flowfile_repository + - nifi-vol-content:/opt/nifi/nifi-current/content_repository + - nifi-vol-state:/opt/nifi/nifi-current/state + + # Flowfile error output + - nifi-vol-errors:/opt/nifi/pipeline/flowfile-errors + + nifi-nginx-tmpfs: &nifi-nginx-tmpfs + - /tmp:mode=1777 + + nifi-nginx: &nifi-nginx-volumes + - ../../../deployment/security/certificates/nifi:/certificates/nifi:ro + - ../../../deployment/security/certificates/root/root-ca.pem:/certificates/root/root-ca.pem:ro + +x-networks: + cognet: &cognet + - cognet + +x-common-ulimits: &common-ulimits + ulimits: + nofile: + soft: 65535 + hard: 65535 + nproc: 65535 + memlock: + soft: -1 + hard: -1 + +x-nifi-common: &nifi-common + <<: *common-ulimits + restart: unless-stopped + env_file: *all-env + networks: *cognet +#---------------------------------------------------------------------------# +# Used services # +#---------------------------------------------------------------------------# +services: + +#---------------------------------------------------------------------------# +# NiFi webapp # +#---------------------------------------------------------------------------# + nifi: + <<: *nifi-common + image: ${NIFI_IMAGE:-cogstacksystems/nifi:latest} + hostname: nifi + shm_size: ${NIFI_DOCKER_SHM_SIZE:-1g} + environment: *nifi-env + deploy: + resources: + limits: + cpus: "${NIFI_DOCKER_CPU_MAX}" + memory: "${NIFI_DOCKER_RAM}" + reservations: + cpus: "${NIFI_DOCKER_CPU_MIN}" + memory: "${NIFI_DOCKER_RAM}" + volumes: *nifi-volumes + + stop_grace_period: 120s + logging: *nifi-logging-common + + nifi-nginx: + image: ${NIFI_NGINX_IMAGE:-cogstacksystems/nginx:latest} + restart: always + shm_size: ${NGINX_SHM_SIZE:-512mb} + environment: *nifi-nginx-env + stop_grace_period: 90s + read_only: true + tmpfs: *nifi-nginx-tmpfs + deploy: + resources: + limits: + cpus: "${NGINX_DOCKER_CPU_MAX:-1}" + memory: "${NGINX_DOCKER_RAM:-1g}" + reservations: + cpus: "${NGINX_DOCKER_CPU_MIN:-1}" + memory: "${NGINX_DOCKER_RAM:-1g}" + volumes: *nifi-nginx-volumes + ports: + - "${NIFI_EXTERNAL_PORT_NGINX:-8443}:${NIFI_INTERNAL_PORT_NGINX:-8443}" + networks: *cognet + logging: *nifi-logging-common + +#---------------------------------------------------------------------------# +# Docker named volumes # +#---------------------------------------------------------------------------# +volumes: + nifi-vol-conf: + # NiFi related + nifi-vol-logs: + driver: local + + nifi-vol-provenance: + driver: local + + nifi-vol-database: + driver: local + + nifi-vol-flowfiles: + driver: local + + nifi-vol-content: + driver: local + + nifi-vol-state: + driver: local + + nifi-vol-errors: + driver: local + +#---------------------------------------------------------------------------# +# Docker networks. # +#---------------------------------------------------------------------------# +networks: + cognet: + name: cogstack-net diff --git a/apps/nifi/docker/docker-compose.dev.yml b/apps/nifi/docker/docker-compose.dev.yml index c3b5f313..e2440b20 100644 --- a/apps/nifi/docker/docker-compose.dev.yml +++ b/apps/nifi/docker/docker-compose.dev.yml @@ -1,304 +1,36 @@ -#---------------------------------------------------------------------------# -# Common snippets / anchors # -#---------------------------------------------------------------------------# - -x-nifi-logging-common: &nifi-logging-common - driver: "json-file" - options: - max-size: ${NIFI_DOCKER_LOG_SIZE_PER_FILE:-250m} - max-file: ${NIFI_DOCKER_LOG_NUM_FILES:-10} - -x-env-files: - all: &all-env - - "${COGSTACK_PROJECT_ENV_FILE:-./project.env}" - - "${COGSTACK_GENERAL_ENV_FILE:-./general.env}" - - "${COGSTACK_NIFI_ENV_FILE:-./nifi.env}" - - "${COGSTACK_GITEA_ENV_FILE:-./gitea.env}" - - "${COGSTACK_NGINX_ENV_FILE:-./nginx.env}" - - "${COGSTACK_TELEMETRY_ENV_FILE:-./telemetry.env}" - - "${COGSTACK_ELASTICSEARCH_ENV_FILE:-./elasticsearch.env}" - - "${COGSTACK_NETWORK_SETTINGS_ENV_FILE:-./network_settings.env}" - - "${COGSTACK_USERS_NIFI_ENV_FILE:-../security/env/users_nifi.env}" - - "${COGSTACK_USERS_NGINX_ENV_FILE:-../security/env/users_nginx.env}" - - "${COGSTACK_USERS_ELASTICSEARCH_ENV_FILE:-../security/env/users_elasticsearch.env}" - - "${COGSTACK_CERTIFICATES_GENERAL_ENV_FILE:-../security/env/certificates_general.env}" - - "${COGSTACK_CERTIFICATES_ELASTICSEARCH_ENV_FILE:-../security/env/certificates_elasticsearch.env}" - - "${COGSTACK_CERTIFICATES_NIFI_ENV_FILE:-../security/env/certificates_nifi.env}" - - search: &es-env - - "${COGSTACK_NETWORK_SETTINGS_ENV_FILE:-./network_settings.env}" - - "${COGSTACK_ELASTICSEARCH_ENV_FILE:-./elasticsearch.env}" - - "${COGSTACK_USERS_ELASTICSEARCH_ENV_FILE:-../security/env/users_elasticsearch.env}" - - "${COGSTACK_CERTIFICATES_ELASTICSEARCH_ENV_FILE:-../security/env/certificates_elasticsearch.env}" - - nifi-nginx: &nifi-nginx-env-files - - "${COGSTACK_NGINX_ENV_FILE:-./nginx.env}" - -x-env: - nifi: &nifi-env - POSTGRES_SAMPLES_DB_NAME: ${POSTGRES_SAMPLES_DB_NAME:-db_samples} - POSTGRES_SAMPLES_JDBC_URL: ${POSTGRES_SAMPLES_JDBC_URL:-jdbc:postgresql://samples-db:5432/${POSTGRES_SAMPLES_DB_NAME:-db_samples}?sslmode=verify-full&sslrootcert=/run/database-cas/samples-ca.crt} - POSTGRES_INGEST_USER_SAMPLES: ${POSTGRES_INGEST_USER_SAMPLES:-cogstack_samples} - POSTGRES_INGEST_PASSWORD_SAMPLES: ${POSTGRES_INGEST_PASSWORD_SAMPLES:?Set the sample ingestion password} - DATABASE_DB_NAME: ${DATABASE_DB_NAME:-cogstack} - DATABASE_INGEST_USER: ${DATABASE_INGEST_USER:-cogstack_ingest} - DATABASE_INGEST_PASSWORD: ${DATABASE_INGEST_PASSWORD:?Set the PostgreSQL ingestion password} - MSSQL_INGEST_USER: ${MSSQL_INGEST_USER:-cogstack_ingest} - MSSQL_INGEST_PASSWORD: ${MSSQL_INGEST_PASSWORD:?Set the MSSQL ingestion password} - - # Apache's native startup settings; existing deployment env names remain supported. - AUTH: ${AUTH:-tls} - NIFI_SECURITY_USER_AUTHORIZER: ${NIFI_SECURITY_USER_AUTHORIZER:-single-user-authorizer} - NIFI_SECURITY_USER_LOGIN_IDENTITY_PROVIDER: ${NIFI_SECURITY_USER_LOGIN_IDENTITY_PROVIDER:-single-user-provider} - SINGLE_USER_CREDENTIALS_USERNAME: ${SINGLE_USER_CREDENTIALS_USERNAME:-${NIFI_SINGLE_USER_CREDENTIALS_USERNAME}} - SINGLE_USER_CREDENTIALS_PASSWORD: ${SINGLE_USER_CREDENTIALS_PASSWORD:-${NIFI_SINGLE_USER_CREDENTIALS_PASSWORD}} - KEYSTORE_PATH: ${KEYSTORE_PATH:-${NIFI_KEYSTORE_PATH}} - KEYSTORE_TYPE: ${KEYSTORE_TYPE:-${NIFI_KEYSTORE_TYPE}} - KEYSTORE_PASSWORD: ${KEYSTORE_PASSWORD:-${NIFI_KEYSTORE_PASSWORD}} - TRUSTSTORE_PATH: ${TRUSTSTORE_PATH:-${NIFI_TRUSTSTORE_PATH}} - TRUSTSTORE_TYPE: ${TRUSTSTORE_TYPE:-${NIFI_TRUSTSTORE_TYPE}} - TRUSTSTORE_PASSWORD: ${TRUSTSTORE_PASSWORD:-${NIFI_TRUSTSTORE_PASSWORD}} - NIFI_WEB_HTTPS_PORT: ${NIFI_WEB_HTTPS_PORT:-${NIFI_INTERNAL_PORT:-8443}} - NIFI_REMOTE_INPUT_SOCKET_PORT: ${NIFI_REMOTE_INPUT_SOCKET_PORT:-${NIFI_INPUT_SOCKET_PORT:-10000}} - PYTHONPATH: ${NIFI_PYTHONPATH:-/opt/nifi/nifi-current/python/framework} - JVM_OPTS: ${NIFI_JVM_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+ParallelRefProcEnabled -Djava.security.egd=file:/dev/./urandom} - - nifi-nginx: &nifi-nginx-env - NIFI_INTERNAL_PORT_NGINX: ${NIFI_INTERNAL_PORT_NGINX:-8443} - NIFI_WEB_PROXY_PORT: ${NIFI_WEB_PROXY_PORT:-8443} - NIFI_INTERNAL_PORT: ${NIFI_INTERNAL_PORT:-8443} - NIFI_UPSTREAM_HOST: ${NIFI_UPSTREAM_HOST:-nifi} - NIFI_UPSTREAM_PORT: ${NIFI_UPSTREAM_PORT:-${NIFI_INTERNAL_PORT:-8443}} - NIFI_UPSTREAM_TLS_NAME: ${NIFI_UPSTREAM_TLS_NAME:-nifi} - -x-mounts: - nifi: &nifi-volumes - # Drivers - - ../drivers:/opt/nifi/drivers:ro - - # User overrides bundled in the image - - ../user_scripts:/opt/nifi/user_scripts:rw - - ../user_schemas:/opt/nifi/user_schemas:ro - - # Python processors (NiFi 2.x) - - ../user_python_extensions:/opt/nifi/nifi-current/python_extensions:rw - - # Security certificates - - ../security/certificates/nifi:/security/certificates/nifi:ro - - ../security/certificates/elastic/opensearch/elasticsearch:/security/certificates/elastic/opensearch/elasticsearch:ro - - ../security/certificates/elastic/opensearch/elastic-stack-ca.crt.pem:/security/certificates/elastic/opensearch/elastic-stack-ca.crt.pem:ro - - ../security/certificates/elastic/opensearch/es_kibana_client.pem:/security/certificates/elastic/opensearch/es_kibana_client.pem:ro - - ../security/certificates/elastic/opensearch/es_kibana_client.key:/security/certificates/elastic/opensearch/es_kibana_client.key:ro - - ../security/certificates/root/root-ca.pem:/security/certificates/root/root-ca.pem:ro - # Database clients receive only the public CA from each TLS bundle. - - type: bind - source: ${POSTGRES_SAMPLES_TLS_DIR:-../security/certificates/postgresql/samples}/ca.crt - target: /run/database-cas/samples-ca.crt - read_only: true - bind: - create_host_path: false - - type: bind - source: ${POSTGRES_DATABANK_TLS_DIR:-../security/certificates/postgresql/databank}/ca.crt - target: /run/database-cas/databank-ca.crt - read_only: true - bind: - create_host_path: false - - # Apache startup configures image defaults in this persistent, writable directory. - - nifi-vol-conf:/opt/nifi/nifi-current/conf - - # Ingest data directory - - ${NIFI_DATA_PATH:-../data/}:/data/:rw - - # MedCAT models - - ${NIFI_MEDCAT_SERVICE_MODEL_PRODUCTION_PATH:-../services/cogstack-nlp/medcat-service/models/}:/opt/models:rw - - # NiFi repositories/state - - nifi-vol-logs:/opt/nifi/nifi-current/logs - - nifi-vol-provenance:/opt/nifi/nifi-current/provenance_repository - - nifi-vol-database:/opt/nifi/nifi-current/database_repository - - nifi-vol-flowfiles:/opt/nifi/nifi-current/flowfile_repository - - nifi-vol-content:/opt/nifi/nifi-current/content_repository - - nifi-vol-state:/opt/nifi/nifi-current/state - - # Flowfile error output - - nifi-vol-errors:/opt/nifi/pipeline/flowfile-errors - - nifi-nginx-tmpfs: &nifi-nginx-tmpfs - - /tmp:mode=1777 - - nifi-nginx: &nifi-nginx-volumes - - ../services/nginx/sites-enabled:/etc/nginx/sites-enabled:ro - - ../security/certificates/nifi:/certificates/nifi:ro - - ../security/certificates/root/root-ca.pem:/certificates/root/root-ca.pem:ro - - otel-collector: &otel-collector-volumes - - ./observability/otel-collector.yaml:/etc/otelcol-contrib/config.yaml:ro - - data-prepper: &data-prepper-volumes - - ./observability/data-prepper/config/data-prepper-config.yaml:/usr/share/data-prepper/config/data-prepper-config.yaml:ro - - ./observability/data-prepper/pipelines:/usr/share/data-prepper/pipelines:ro - -x-networks: - cognet: &cognet - - cognet - -x-common-hosts: &common-hosts - - ${ELASTICSEARCH_1_HOST_NAME:-test-1:0.0.0.0} - - ${ELASTICSEARCH_2_HOST_NAME:-test-2:0.0.0.0} - - ${ELASTICSEARCH_3_HOST_NAME:-test-3:0.0.0.0} - - ${KIBANA_HOST_NAME:-test-4:0.0.0.0} - - ${NIFI_HOST_NAME:-test-5:0.0.0.0} - -x-common-ulimits: &common-ulimits - ulimits: - nofile: - soft: 65535 - hard: 65535 - nproc: 65535 - memlock: - soft: -1 - hard: -1 - -x-nifi-common: &nifi-common - <<: *common-ulimits - restart: unless-stopped - env_file: *all-env - extra_hosts: *common-hosts - networks: *cognet -#---------------------------------------------------------------------------# -# Used services # -#---------------------------------------------------------------------------# services: - -#---------------------------------------------------------------------------# -# NiFi webapp # -#---------------------------------------------------------------------------# nifi: - <<: *nifi-common - image: ${NIFI_LOCAL_DOCKER_IMAGE:-cogstack/cogstack-nifi:local} + container_name: cogstack-nifi + image: ${NIFI_LOCAL_DOCKER_IMAGE:-cogstacksystems/nifi:local} pull_policy: build build: - context: .. - dockerfile: Dockerfile - args: - NIFI_VERSION: ${NIFI_VERSION:-2.12.0} - NIFI_BASE_IMAGE: ${NIFI_BASE_IMAGE:?Source deploy/export_env_vars.sh first} - NIFI_UID: ${COGSTACK_LOCAL_UID:-1000} - NIFI_GID: ${COGSTACK_LOCAL_GID:-1000} - container_name: cogstack-nifi - hostname: nifi - shm_size: ${NIFI_DOCKER_SHM_SIZE:-"1g"} - environment: *nifi-env - deploy: - resources: - limits: - cpus: "${NIFI_DOCKER_CPU_MAX}" - memory: "${NIFI_DOCKER_RAM}" - reservations: - cpus: "${NIFI_DOCKER_CPU_MIN}" - memory: "${NIFI_DOCKER_RAM}" - volumes: *nifi-volumes - - stop_grace_period: 120s + context: .. + dockerfile: Dockerfile + args: + NIFI_VERSION: ${NIFI_VERSION:-2.12.0} + NIFI_BASE_IMAGE: ${NIFI_BASE_IMAGE:?Source docker/export_env_vars.sh first} + NIFI_UID: ${COGSTACK_LOCAL_UID:-1000} + NIFI_GID: ${COGSTACK_LOCAL_GID:-1000} + volumes: + - ../drivers:/opt/nifi/drivers:ro + - ../user_scripts:/opt/nifi/user_scripts:rw + - ../user_schemas:/opt/nifi/user_schemas:ro + - ../user_python_extensions:/opt/nifi/nifi-current/python_extensions:rw ports: - "${NIFI_OUTPUT_PORT:-8082}:${NIFI_INTERNAL_PORT:-8443}" - "${NIFI_INPUT_SOCKET_PORT:-10000}" - logging: *nifi-logging-common - + nifi-nginx: + container_name: cogstack-nifi-nginx + image: cogstacksystems/nginx:local pull_policy: build build: - context: ../services/nginx + context: ../../nginx dockerfile: Dockerfile args: NGINX_UID: ${COGSTACK_LOCAL_UID:-1000} NGINX_GID: ${COGSTACK_LOCAL_GID:-1000} - container_name: cogstack-nifi-nginx - restart: always - shm_size: ${NGINX_SHM_SIZE:-512mb} - env_file: *nifi-nginx-env-files - environment: *nifi-nginx-env - stop_grace_period: 90s - read_only: true - tmpfs: *nifi-nginx-tmpfs - deploy: - resources: - limits: - cpus: "${NGINX_DOCKER_CPU_MAX}" - memory: "${NGINX_DOCKER_RAM}" - reservations: - cpus: "${NGINX_DOCKER_CPU_MIN}" - memory: "${NGINX_DOCKER_RAM}" - volumes: *nifi-nginx-volumes - ports: - - "${NIFI_EXTERNAL_PORT_NGINX:-8443}:${NIFI_INTERNAL_PORT_NGINX:-8443}" - networks: *cognet - extra_hosts: *common-hosts - logging: *nifi-logging-common - -#---------------------------------------------------------------------------# -# Observability stack # -#---------------------------------------------------------------------------# - otel-collector: - image: ${OTEL_COLLECTOR_DOCKER_IMAGE:?Source deploy/export_env_vars.sh first} - container_name: cogstack-otel-collector - restart: unless-stopped - command: ["--config=/etc/otelcol-contrib/config.yaml"] - env_file: *all-env - volumes: *otel-collector-volumes - ports: - - "${OTEL_COLLECTOR_OTLP_GRPC_PORT:-4317}:4317" - - "${OTEL_COLLECTOR_OTLP_HTTP_PORT:-4318}:4318" - - "${OTEL_COLLECTOR_HEALTH_PORT:-13133}:13133" - networks: *cognet - extra_hosts: *common-hosts - logging: *nifi-logging-common - - data-prepper: - image: ${DATA_PREPPER_DOCKER_IMAGE:?Source deploy/export_env_vars.sh first} - container_name: cogstack-data-prepper - restart: unless-stopped - env_file: *all-env - volumes: *data-prepper-volumes - ports: - - "${DATA_PREPPER_API_PORT:-4900}:4900" - - "${DATA_PREPPER_OTEL_TRACE_PORT:-21890}:21890" - networks: *cognet - extra_hosts: *common-hosts - logging: *nifi-logging-common - -#---------------------------------------------------------------------------# -# Docker named volumes # -#---------------------------------------------------------------------------# -volumes: - nifi-vol-conf: - # NiFi related - nifi-vol-logs: - driver: local - - nifi-vol-provenance: - driver: local - - nifi-vol-database: - driver: local - - nifi-vol-flowfiles: - driver: local - - nifi-vol-content: - driver: local - - nifi-vol-state: - driver: local - - nifi-vol-errors: - driver: local -#---------------------------------------------------------------------------# -# Docker networks. # -#---------------------------------------------------------------------------# networks: cognet: - driver: bridge - name: cogstack-net + name: nifi-dev-net diff --git a/apps/nifi/docker/docker-compose.prod.yml b/apps/nifi/docker/docker-compose.prod.yml new file mode 100644 index 00000000..cec3e1a5 --- /dev/null +++ b/apps/nifi/docker/docker-compose.prod.yml @@ -0,0 +1,5 @@ +name: nifi + +networks: + cognet: + external: true diff --git a/apps/nifi/docker/docker-compose.yml b/apps/nifi/docker/docker-compose.yml new file mode 100644 index 00000000..f0586041 --- /dev/null +++ b/apps/nifi/docker/docker-compose.yml @@ -0,0 +1,4 @@ +name: nifi + +include: + - docker-compose.base.yml diff --git a/apps/nifi/docker/export_env_vars.sh b/apps/nifi/docker/export_env_vars.sh index f62884b1..988dfaac 100755 --- a/apps/nifi/docker/export_env_vars.sh +++ b/apps/nifi/docker/export_env_vars.sh @@ -11,42 +11,23 @@ _cogstack_load_environment() { fi local deploy_path deploy_path="$(cd "$(dirname "$loader_path")" && pwd)" || return 1 - # shellcheck disable=SC1091 - source "$deploy_path/config_files.sh" || return 1 - cogstack_config_init "$(cd "$deploy_path/.." && pwd)" || return 1 - local relative_files=( - security/env/certificates_nifi.env - security/env/certificates_general.env - security/env/certificates_elasticsearch.env - security/env/users_elasticsearch.env - security/env/users_database.env - security/env/users_nifi.env - security/env/users_nginx.env - deploy/general.env - deploy/nifi.env - deploy/elasticsearch.env - deploy/ollama.env - deploy/sglang.env - deploy/openwebui.env - deploy/database.env - deploy/network_settings.env - deploy/project.env - deploy/gitea.env - deploy/nginx.env - deploy/telemetry.env + ../env/general.env + ../env/nifi.env ) local relative_file selected_file variable_name file_name local restore_allexport=1 case "$-" in *a*) restore_allexport=0 ;; esac set -a for relative_file in "${relative_files[@]}"; do - selected_file="$(cogstack_env_file "$relative_file")" || { - if [[ "$restore_allexport" == 1 ]]; then set +a; fi - return 1 - } file_name="${relative_file##*/}" variable_name="COGSTACK_$(printf '%s' "${file_name%.env}" | tr '[:lower:]' '[:upper:]')_ENV_FILE" + if [[ -n "${ZSH_VERSION:-}" ]]; then + eval 'selected_file=${(P)variable_name:-}' + else + selected_file="${!variable_name:-}" + fi + selected_file="${selected_file:-$deploy_path/$relative_file}" export "$variable_name=$selected_file" # shellcheck disable=SC1090 source "$selected_file" || { @@ -56,25 +37,6 @@ _cogstack_load_environment() { } done - # Service-owned configuration remains optional and uses its own directories. - local service_files=( - ../jupyter-hub/env/jupyter.env - services/cogstack-platform/apps/ocr-service/env/ocr_service.env - services/cogstack-nlp/medcat-service/env/app.env - services/cogstack-nlp/medcat-service/env/medcat.env - services/cogstack-nlp/medcat-trainer/envs/env-prod - ) - for relative_file in "${service_files[@]}"; do - selected_file="$COGSTACK_REPO_ROOT/$relative_file" - if [[ -f "$selected_file" ]]; then - # shellcheck disable=SC1090 - source "$selected_file" || { - echo "ERROR: Failed to load service configuration: $selected_file" >&2 - if [[ "$restore_allexport" == 1 ]]; then set +a; fi - return 1 - } - fi - done # Local image builds match bind-mounted configuration/certificate ownership. # Published images retain their Dockerfile's default non-root UID/GID. export COGSTACK_LOCAL_UID="${COGSTACK_LOCAL_UID:-$(id -u)}" @@ -83,7 +45,7 @@ _cogstack_load_environment() { if [[ "$COGSTACK_LOCAL_GID" == 0 ]]; then export COGSTACK_LOCAL_GID=1000; fi export DOLLAR='$' if [[ "$restore_allexport" == 1 ]]; then set +a; fi - echo "Configuration loaded from ${COGSTACK_CONFIG_DIR:-repository defaults}." + echo "Configuration loaded." } if _cogstack_load_environment; then diff --git a/deployment/.gitignore b/deployment/.gitignore new file mode 100644 index 00000000..7893fda1 --- /dev/null +++ b/deployment/.gitignore @@ -0,0 +1,7 @@ +# Deployment links to app env files included in the repository. +!/env/ +/env/* +!/env/cohorter.env +!/env/jupyter.env +!/env/ocr_service.env +!/env/ocr_service_text_only.env diff --git a/deployment/env/cohorter.env b/deployment/env/cohorter.env new file mode 120000 index 00000000..6d2d7595 --- /dev/null +++ b/deployment/env/cohorter.env @@ -0,0 +1 @@ +../../apps/cohorter/env/cohorter.env \ No newline at end of file diff --git a/deployment/env/jupyter.env b/deployment/env/jupyter.env new file mode 120000 index 00000000..5c824515 --- /dev/null +++ b/deployment/env/jupyter.env @@ -0,0 +1 @@ +../../apps/jupyter-hub/env/jupyter.env \ No newline at end of file diff --git a/deployment/env/ocr_service.env b/deployment/env/ocr_service.env new file mode 120000 index 00000000..d65091cd --- /dev/null +++ b/deployment/env/ocr_service.env @@ -0,0 +1 @@ +../../apps/ocr-service/env/ocr_service.env \ No newline at end of file diff --git a/deployment/env/ocr_service_text_only.env b/deployment/env/ocr_service_text_only.env new file mode 120000 index 00000000..dd73e74b --- /dev/null +++ b/deployment/env/ocr_service_text_only.env @@ -0,0 +1 @@ +../../apps/ocr-service/env/ocr_service_text_only.env \ No newline at end of file diff --git a/deployment/security/certificates/.gitignore b/deployment/security/certificates/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/deployment/security/certificates/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore