Data and tmp standardization #1279
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements a major simplification of the NetAlertX Docker filesystem, consolidating all persistent data into a single
/datavolume and all ephemeral runtime data into a single/tmptmpfsmount.🧐 Why is this necessary?
The previous mount structure was complex, requiring users to manage two separate persistent volumes (
netalertx_config,netalertx_db) and a list of up to fivetmpfsmounts. This created a high barrier to entry and was prone to misconfiguration.This new structure aligns with best practices and simplifies the user experience for all use cases, from a simple
docker compose upat home to complex, air-gapped enterprise deployments.🛠️ Summary of Changes
This PR touches nearly every layer of the container to achieve this simplification, from the
Dockerfileto the application-level PHP code.1. Filesystem & Mounts
docker-compose.yml:netalertx_configandnetalertx_dbvolumes.datamounted to/data.tmpfsmounts (e.g.,/tmp/log,/tmp/api,/tmp/run).tmpfsmount for/tmp, which now contains all runtime/ephemeral subdirectories.Dockerfile:/dataand/tmpbase directories with correct20211:20211/700permissions.NETALERTX_CONFIG_DIR,NETALERTX_DB_DIR,NETALERTX_LOG_DIR, etc.) have been updated to point to the new paths (e.g.,/data/config,/data/db,/tmp/log).2. Path Abstraction & Code Updates
server/config_paths.py) instead of hard-coded paths like/app/config,/app/db, or/app/api.front/php/server/util.phpwas still referencing/app/api/table_settings.json, causing PHP-FPM to hang on startup. It now correctly uses the abstracted path.3. Entrypoint & Migration Logic
entrypoint.d/01-data-migration.sh(New):entrypoint.d/25-mandatory-folders.sh(New):/dataand/tmp(e.g.,/data/config,/data/db,/tmp/log,/tmp/api,/tmp/run,/tmp/nginx/active-config). This ensures the container functions correctly whether the user mounts the root/dataand/tmpor individual sub-mounts.entrypoint.sh(Updated):entrypoint.dscript exits with status1(indicating a critical, system-breaking error), the container will print a standardized error message with a troubleshooting link and exit.chowncommands per review feedback.🗺️ Migration Path for Existing Users
This change includes an assisted migration to move data from old volumes.
/datavolume to theirdocker-compose.ymlwhile keeping their oldnetalertx_configandnetalertx_dbvolumes.01-data-migration.shwill detect this hybrid state./app/configand/app/dbinto the new/data/configand/data/dbdirectories..migrationfiles in the old volumes and print a persistent warning on every startup, instructing the user to shut down, remove the oldnetalertx_configandnetalertx_dbvolume definitions, and restart.docker-compose.ymlis updated to only use the/datavolume, the warnings will cease.✅ Testing & Validation
test/docker_tests/configurations/were updated to reflect the new mount structure.test_mount_diagnosticswas updated to parse the new warning tables and assert their contents directly.test_missing_host_network_warningis now passing.-v /tmp/log:/tmp/log) and root mounts (-v data:/data) functions correctly anddevices.phpis available.New Features
Some additional items were added to reduce development complexity.
.devcontainer/NetAlertX.code-workspaceWorkspace was added which allows quick access to logs and other out-of-source inspections during normal operation💬 Addressed Code Review Feedback
1inentrypoint.sh. which reduced complexity in implementationFuture enhancements