Fix user retention - #62
Merged
Merged
Conversation
- Add is_running_in_container() function to detect Docker/Podman environments - Add get_persistent_data_dir() function to determine where to store persistent data - On native Linux: use /var/lib/openplc-runtime for .env and database files - On containers: continue using /var/run/runtime (mounted as persistent volume) - Update installer to create /var/lib/openplc-runtime when systemd is available This fixes the issue where user credentials were lost after reboot because /var/run/runtime is a tmpfs that gets cleared on reboot. The .env file regeneration would then delete the database since new secrets invalidate old password hashes. Container detection checks: - /.dockerenv file existence - container/DOCKER_CONTAINER environment variables - /proc/1/cgroup for docker/kubepods/lxc/containerd patterns - /proc/1/environ for container= variable Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
…persistence Fix user data persistence across reboots for native Linux installs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 improves the handling of runtime and persistent data directories for both containerized and native Linux installations. The changes ensure that data such as the
.envfile and database are stored in the correct location depending on the environment, increasing robustness and making sure persistent data survives system reboots outside containers. A new utility function also detects whether the application is running inside a container.Persistent data management improvements:
get_persistent_data_dir()function inwebserver/config.pyto select the appropriate directory for persistent data based on whether the app is running in a container or on native Linux/MSYS2. Persistent data is now stored in/var/lib/openplc-runtimeon native Linux, and/var/run/runtimein containers and MSYS2/Windows.ENV_PATHandDB_PATHinwebserver/config.pyto use the new persistent data directory, ensuring these files are stored in a location that survives reboots on native Linux.Container detection and directory setup:
is_running_in_container()function inwebserver/config.pyto robustly detect if the application is running inside a container using multiple heuristics.install.shto create/var/lib/openplc-runtimewith appropriate permissions for native Linux installs with systemd support, ensuring the persistent data directory exists.Documentation and comments:
webserver/config.pyto clarify the logic for selecting runtime and persistent data directories depending on platform and environment.