From 993ab83563dc15ec19e9180ba25e46a1e2686249 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Thu, 5 Nov 2026 19:51:50 +0200 Subject: [PATCH 01/10] add init support for documentdb --- docker-compose.documentdb.yml | 61 ++++++++++++++++++++++++++++ scripts/init_storage_default_dirs.sh | 3 +- services/documentdb/custom-entry.sh | 6 +++ services/fastnetmon/custom-entry.sh | 11 +++++ volumes.yml | 8 +++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 docker-compose.documentdb.yml create mode 100755 services/documentdb/custom-entry.sh diff --git a/docker-compose.documentdb.yml b/docker-compose.documentdb.yml new file mode 100644 index 0000000..b7c66d7 --- /dev/null +++ b/docker-compose.documentdb.yml @@ -0,0 +1,61 @@ +services: + documentdb: + # https://documentdb.io/docs/getting-started/docker/ + image: ghcr.io/documentdb/documentdb/documentdb-local:pg18-1.0.0 + networks: + - fastnetmon-network + restart: unless-stopped + volumes: + - documentdb_data:/data + - ${FNM_PATH}/services/documentdb/custom-entry.sh:/custom-entry.sh:ro + secrets: + - mongo_password + environment: + USERNAME: administrator + PASSWORD_FILE: /run/secrets/mongo_password + DOCUMENTDB_USAGE_TELEMETRY: false + TLS_MODE: disabled + DOCUMENTDB_PORT: 27017 + entrypoint: [ "/bin/bash", "/custom-entry.sh" ] + #healthcheck: + # test: [ "CMD", "mongosh", "--eval", "db.adminCommand('ping')", "--quiet" ] + # interval: 1m30s + # timeout: 30s + # retries: 5 + # start_period: 40s + + + documentdb-configure: + # need enable collation for LiveView + image: ghcr.io/documentdb/documentdb/documentdb-local:pg18-1.0.0 + network_mode: "service:documentdb" + user: documentdb + entrypoint: [ "/bin/bash", "-ec" ] + command: + - | + until pg_isready -h 127.0.0.1 -p 9712 -U documentdb; do + sleep 1 + done + + psql -X -v ON_ERROR_STOP=1 \ + -h 127.0.0.1 -p 9712 \ + -U documentdb -d postgres <<'SQL' + ALTER SYSTEM SET documentdb_core.enableCollation = 'on'; + SELECT pg_reload_conf(); + SQL + + psql -X -h 127.0.0.1 -p 9712 \ + -U documentdb -d postgres \ + -c "SELECT current_setting('documentdb_core.enableCollation');" + depends_on: + documentdb: + condition: service_healthy + restart: "no" + + fastnetmon: + depends_on: + documentdb: + condition: service_healthy + environment: + MONGO_HOST: documentdb + DOCUMENTDB_ENABLED: true diff --git a/scripts/init_storage_default_dirs.sh b/scripts/init_storage_default_dirs.sh index c68d3dd..bcf2c6b 100755 --- a/scripts/init_storage_default_dirs.sh +++ b/scripts/init_storage_default_dirs.sh @@ -28,5 +28,4 @@ touch "${PROJECT_DIR}/storage/clickhouse/logs/.gitkeep" mkdir -p "${PROJECT_DIR}/storage/grafana/data/" touch "${PROJECT_DIR}/storage/grafana/data/.gitkeep" - - +mkdir -p "${PROJECT_DIR}/storage/documentdb/data/" \ No newline at end of file diff --git a/services/documentdb/custom-entry.sh b/services/documentdb/custom-entry.sh new file mode 100755 index 0000000..ca2896e --- /dev/null +++ b/services/documentdb/custom-entry.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e + +export PASSWORD="$(cat /run/secrets/mongo_password)" + +exec /home/documentdb/gateway/scripts/emulator_entrypoint.sh "$@" diff --git a/services/fastnetmon/custom-entry.sh b/services/fastnetmon/custom-entry.sh index db33026..be38868 100755 --- a/services/fastnetmon/custom-entry.sh +++ b/services/fastnetmon/custom-entry.sh @@ -13,6 +13,17 @@ cat > /etc/fastnetmon/fastnetmon.conf < /etc/fastnetmon/fastnetmon.conf < /etc/fastnetmon/fastnetmon.conf < Date: Fri, 6 Nov 2026 13:11:32 +0200 Subject: [PATCH 02/10] refactor init_storage_default_dirs.sh --- scripts/init_storage_default_dirs.sh | 56 +++++++++++++++++----------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/scripts/init_storage_default_dirs.sh b/scripts/init_storage_default_dirs.sh index bcf2c6b..7450342 100755 --- a/scripts/init_storage_default_dirs.sh +++ b/scripts/init_storage_default_dirs.sh @@ -8,24 +8,38 @@ if [ ! -f "./docker-compose.yml" ]; then exit 1 fi -mkdir -p "${PROJECT_DIR}/storage/mongo/data/" -touch "${PROJECT_DIR}/storage/mongo/data/.gitkeep" -touch "${PROJECT_DIR}/storage/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/fastnetmon/logs/" -touch "${PROJECT_DIR}/storage/fastnetmon/logs/.gitkeep" -touch "${PROJECT_DIR}/storage/fastnetmon/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/fastnetmon_web_api/logs/" -touch "${PROJECT_DIR}/storage/fastnetmon_web_api/logs/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/clickhouse/data/" -touch "${PROJECT_DIR}/storage/clickhouse/data/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/clickhouse/logs/" -touch "${PROJECT_DIR}/storage/clickhouse/logs/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/grafana/data/" -touch "${PROJECT_DIR}/storage/grafana/data/.gitkeep" - -mkdir -p "${PROJECT_DIR}/storage/documentdb/data/" \ No newline at end of file +DIRECTORYS=" +mongo/data/ +fastnetmon/logs/ +fastnetmon/logs/attacks_dumps +fastnetmon_web_api/logs/ +clickhouse/data/ +clickhouse/logs/ +grafana/data +documentdb/data +" + +GIT_KEEPS=" +.gitkeep +mongo/data/.gitkeep +fastnetmon/logs/.gitkeep +fastnetmon/.gitkeep +fastnetmon_web_api/logs/.gitkeep +clickhouse/data/.gitkeep +clickhouse/logs/.gitkeep +grafana/data/.gitkeep +" + +echo "Create storage dirs" +for dir in $DIRECTORYS; do + echo "Create $dir" + mkdir -p "${PROJECT_DIR}/storage/${dir}" +done + +echo "Recreate storage .gitkeep files" +for file in $GIT_KEEPS; do + touch "${PROJECT_DIR}/storage/${file}" +done + +echo "Done" +exit 0 From 714c33db510f89d1336a16d0caed5cf3eb47236e Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 14:13:28 +0200 Subject: [PATCH 03/10] move documentdb version to env --- .env.template | 1 + docker-compose.documentdb.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.env.template b/.env.template index 3db9614..7cbab1b 100644 --- a/.env.template +++ b/.env.template @@ -2,6 +2,7 @@ FNM_PATH=${PWD} FNM_VERSION=latest FNM_WEB_API_V2=true FNM_NOT_UPLOAD_ASN_MAPPING=false +FNM_DOCUMENTDB_VERSION=pg18-1.0.0 COMPOSE_PROJECT_NAME=fnm COMPOSE_FILE=docker-compose.yml:docker-compose.mongo.yml:docker-compose.gobgp.yml:docker-compose.clickhouse.yml:docker-compose.grafana.yml:docker-compose.trafficdb.yml:docker-compose.web-api.yml diff --git a/docker-compose.documentdb.yml b/docker-compose.documentdb.yml index b7c66d7..b6fd0dc 100644 --- a/docker-compose.documentdb.yml +++ b/docker-compose.documentdb.yml @@ -1,7 +1,7 @@ services: documentdb: # https://documentdb.io/docs/getting-started/docker/ - image: ghcr.io/documentdb/documentdb/documentdb-local:pg18-1.0.0 + image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-latest} networks: - fastnetmon-network restart: unless-stopped @@ -27,7 +27,7 @@ services: documentdb-configure: # need enable collation for LiveView - image: ghcr.io/documentdb/documentdb/documentdb-local:pg18-1.0.0 + image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-latest} network_mode: "service:documentdb" user: documentdb entrypoint: [ "/bin/bash", "-ec" ] From 64db9ec279a9d54c70fb19f66fdc950cb26754fd Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 15:57:57 +0200 Subject: [PATCH 04/10] move /var/lib/fastnetmon and /var/cache/fastetmon to volumes --- .gitignore | 3 ++- docker-compose.yml | 2 ++ scripts/init_storage_default_dirs.sh | 2 ++ volumes.yml | 12 ++++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 14c106c..c80742c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /storage/*/logs/* !/storage/*/logs/.gitkeep +/storage/*/lib/* /seeds/fastnetmon/* !/seeds/fastnetmon/.gitkeep @@ -14,4 +15,4 @@ secrets/* /.env -/lab/* \ No newline at end of file +/lab/* diff --git a/docker-compose.yml b/docker-compose.yml index 1f74c09..3670f6b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,8 @@ services: FNM_NOT_UPLOAD_ASN_MAPPING: ${FNM_NOT_UPLOAD_ASN_MAPPING:-false} volumes: - fastnetmon_logs:/var/log/fastnetmon/ + - fastnetmon_lib:/var/lib/fastnetmon/ + - fastnetmon_cache:/var/cache/fastnetmon/ - ${FNM_PATH}/services/fastnetmon/custom-entry.sh:/custom-entry.sh:ro - ${FNM_PATH}/seeds/fastnetmon/:/etc/fastnetmon/ ports: diff --git a/scripts/init_storage_default_dirs.sh b/scripts/init_storage_default_dirs.sh index 7450342..456c544 100755 --- a/scripts/init_storage_default_dirs.sh +++ b/scripts/init_storage_default_dirs.sh @@ -12,6 +12,8 @@ DIRECTORYS=" mongo/data/ fastnetmon/logs/ fastnetmon/logs/attacks_dumps +fastnetmon/lib/ +fastnetmon/cache/ fastnetmon_web_api/logs/ clickhouse/data/ clickhouse/logs/ diff --git a/volumes.yml b/volumes.yml index 0a85bd2..c7fbaf1 100644 --- a/volumes.yml +++ b/volumes.yml @@ -11,6 +11,18 @@ volumes: o: bind device: "${FNM_PATH}/storage/fastnetmon/logs" + fastnetmon_lib: + driver_opts: + type: none + o: bind + device: "${FNM_PATH}/storage/fastnetmon/lib" + + fastnetmon_cache: + driver_opts: + type: none + o: bind + device: "${FNM_PATH}/storage/fastnetmon/cache" + fastnetmon_web_api_logs: driver_opts: type: none From 228c1cf93ab64192ba192aec437cd89eb030eb75 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 16:06:07 +0200 Subject: [PATCH 05/10] update default version for documentdb image and add documentdb to README --- README.md | 2 ++ docker-compose.documentdb.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab05fd7..bb7369e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ We set there variables - `FNM_NOT_UPLOAD_ASN_MAPPING` - disable upload [asn mapping](https://fastnetmon.com/fastnetmon-asn-peering-reports/) - `COMPOSE_PROJECT_NAME` - project name( will be prefix for containers names ). - `COMPOSE_FILE` - declare what components will be used. +- `FNM_DOCUMENTDB_VERSION` - **DocumetnDB** image version, if it is enabled via `COMPOSE_FILE` ### COMPOSE_FILE ### @@ -47,6 +48,7 @@ Components by file - docker-compose.trafficdb.yml - enable [traffic persistence](https://fastnetmon.com/docs-fnm-advanced/fastnetmon-advanced-traffic-persistency/)(need enabled clickhouse) - docker-compose.web-api.yml - start [web API](https://fastnetmon.com/docs-fnm-advanced/advanced-api/) or with FNM_WEB_API_V2=true start [LiveView](https://fastnetmon.com/docs-fnm-advanced/fastnetmon-panel-ui-installation/) - docker-compose.ferretdb.yml - use FerretDB instead of MongoDB +- docker-compose.documentdb.yml - use DocumentDB instead of MongoDB ### Configure volumes and secrets ### diff --git a/docker-compose.documentdb.yml b/docker-compose.documentdb.yml index b6fd0dc..7223ec3 100644 --- a/docker-compose.documentdb.yml +++ b/docker-compose.documentdb.yml @@ -1,7 +1,7 @@ services: documentdb: # https://documentdb.io/docs/getting-started/docker/ - image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-latest} + image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-pg18-1.0.0} networks: - fastnetmon-network restart: unless-stopped @@ -27,7 +27,7 @@ services: documentdb-configure: # need enable collation for LiveView - image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-latest} + image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-pg18-1.0.0} network_mode: "service:documentdb" user: documentdb entrypoint: [ "/bin/bash", "-ec" ] From b16658b5ab4e85a228748e27c7a16ea201a6bd45 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 16:45:06 +0200 Subject: [PATCH 06/10] update matrix, more use of documentdb --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79642fc..4fd2e0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,14 @@ jobs: fail-fast: false matrix: include: - - name: Minimal test + - name: Minimal test MongoDB compose_file: docker-compose.yml:docker-compose.mongo.yml - - name: All comopose files test - compose_file: docker-compose.yml:docker-compose.mongo.yml:docker-compose.clickhouse.yml:docker-compose.grafana.yml:docker-compose.trafficdb.yml:docker-compose.web-api.yml:docker-compose.gobgp.yml + - name: Minimal test DocumentDB + compose_file: docker-compose.yml:docker-compose.documentdb.yml + + - name: All comopose files test DocumentDB + compose_file: docker-compose.yml:docker-compose.documentdb.yml:docker-compose.clickhouse.yml:docker-compose.grafana.yml:docker-compose.trafficdb.yml:docker-compose.web-api.yml:docker-compose.gobgp.yml with: runner: ${{ matrix.runner || 'ubuntu-24.04'}} compose_file: ${{ matrix.compose_file }} From 0b8e828b440fecb8dd6c94f10cf7979572099a85 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 17:00:42 +0200 Subject: [PATCH 07/10] fix for correct exit with --wait --- docker-compose.documentdb.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-compose.documentdb.yml b/docker-compose.documentdb.yml index 7223ec3..1aa3841 100644 --- a/docker-compose.documentdb.yml +++ b/docker-compose.documentdb.yml @@ -51,11 +51,15 @@ services: documentdb: condition: service_healthy restart: "no" + healthcheck: + disable: true fastnetmon: depends_on: documentdb: condition: service_healthy + documentdb-configure: + condition: service_completed_successfully environment: MONGO_HOST: documentdb DOCUMENTDB_ENABLED: true From f4c486962c17b24aab17cc47d9288d712b1c6b40 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 17:37:10 +0200 Subject: [PATCH 08/10] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bb7369e..65c8f19 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Components by file Volumes, secrets and network config separtaed to files volumes.yml,secrets.yml and networks.yml. By default volumes is directoies in `storage/`. +To create deafult directories, please run `scripts/init_storage_default_dirs.sh` script. Secrets are stored in `secrets/` and can be generated with the `scripts/init_secrets.sh` script. From 21dab56d478038cfe2b153a1f409797f0986fa17 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 17:48:45 +0200 Subject: [PATCH 09/10] fix to documentdb/custom-entry.sh --- services/documentdb/custom-entry.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/documentdb/custom-entry.sh b/services/documentdb/custom-entry.sh index ca2896e..6125e55 100755 --- a/services/documentdb/custom-entry.sh +++ b/services/documentdb/custom-entry.sh @@ -1,6 +1,7 @@ #!/bin/sh set -e -export PASSWORD="$(cat /run/secrets/mongo_password)" +PASSWORD_FILE="${PASSWORD_FILE:-/run/secrets/mongo_password}" +export PASSWORD="$(cat $PASSWORD_FILE)" exec /home/documentdb/gateway/scripts/emulator_entrypoint.sh "$@" From dd37785740eb7504687cc20685656873c82bdc9d Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Fri, 6 Nov 2026 17:50:15 +0200 Subject: [PATCH 10/10] fix typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65c8f19..fd571ab 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Components by file Volumes, secrets and network config separtaed to files volumes.yml,secrets.yml and networks.yml. By default volumes is directoies in `storage/`. -To create deafult directories, please run `scripts/init_storage_default_dirs.sh` script. +To create default directories, please run `scripts/init_storage_default_dirs.sh` script. Secrets are stored in `secrets/` and can be generated with the `scripts/init_secrets.sh` script.