Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/storage/*/logs/*
!/storage/*/logs/.gitkeep

/storage/*/lib/*

/seeds/fastnetmon/*
!/seeds/fastnetmon/.gitkeep
Expand All @@ -14,4 +15,4 @@ secrets/*

/.env

/lab/*
/lab/*
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

Expand All @@ -47,11 +48,13 @@ 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 ###

Volumes, secrets and network config separtaed to files volumes.yml,secrets.yml and networks.yml.
By default volumes is directoies in `storage/`.
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.

Expand Down
65 changes: 65 additions & 0 deletions docker-compose.documentdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
services:
documentdb:
# https://documentdb.io/docs/getting-started/docker/
image: ghcr.io/documentdb/documentdb/documentdb-local:${FNM_DOCUMENTDB_VERSION:-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:${FNM_DOCUMENTDB_VERSION:-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"
healthcheck:
disable: true

fastnetmon:
depends_on:
documentdb:
condition: service_healthy
Comment thread
Copilot marked this conversation as resolved.
Resolved
documentdb-configure:
condition: service_completed_successfully
environment:
MONGO_HOST: documentdb
DOCUMENTDB_ENABLED: true
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Comment on lines +26 to +27
- ${FNM_PATH}/services/fastnetmon/custom-entry.sh:/custom-entry.sh:ro
- ${FNM_PATH}/seeds/fastnetmon/:/etc/fastnetmon/
ports:
Expand Down
59 changes: 37 additions & 22 deletions scripts/init_storage_default_dirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,40 @@ 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"



DIRECTORYS="
mongo/data/
fastnetmon/logs/
fastnetmon/logs/attacks_dumps
fastnetmon/lib/
fastnetmon/cache/
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
7 changes: 7 additions & 0 deletions services/documentdb/custom-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e

PASSWORD_FILE="${PASSWORD_FILE:-/run/secrets/mongo_password}"
export PASSWORD="$(cat $PASSWORD_FILE)"

exec /home/documentdb/gateway/scripts/emulator_entrypoint.sh "$@"
11 changes: 11 additions & 0 deletions services/fastnetmon/custom-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ cat > /etc/fastnetmon/fastnetmon.conf <<EOF
"mongodb_username": ""
}
EOF
elif [[ "${DOCUMENTDB_ENABLED}" == "true" ]]; then
cat > /etc/fastnetmon/fastnetmon.conf <<EOF
{
"mongodb_host": "${MONGO_HOST}",
"mongodb_port": 27017,
"mongodb_database_name": "fastnetmon",
"mongodb_username": "${MONGO_USERNAME}",
"mongodb_auth_source": "admin",
"mongodb_auth_mechanism": "SCRAM-SHA-256"
}
EOF
else
cat > /etc/fastnetmon/fastnetmon.conf <<EOF
{
Expand Down
20 changes: 19 additions & 1 deletion volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,4 +45,10 @@ volumes:
driver_opts:
type: none
o: bind
device: "${FNM_PATH}/storage/grafana/data"
device: "${FNM_PATH}/storage/grafana/data"

documentdb_data:
driver_opts:
type: none
o: bind
device: "${FNM_PATH}/storage/documentdb/data"
Loading