Skip to content

refactor: make configuration read-only at runtime and improve settings for Docker environments - #28

Open
IllusionOfControl wants to merge 2 commits into
Mag1cFall:mainfrom
IllusionOfControl:refactor/readonly-config
Open

IllusionOfControl wants to merge 2 commits into
Mag1cFall:mainfrom
IllusionOfControl:refactor/readonly-config

Conversation

@IllusionOfControl

Copy link
Copy Markdown
Contributor

Description

Motivation (Docker Context)

Previously, saving settings in the Web UI attempted to rewrite the .env file via atomic rename (os.Rename).
In Docker container environments, this causes critical issues:

  1. Mount errors (EBUSY: Device or resource busy): when bind-mounting an .env file into a container (volumes: [ ./.env:/app/.env ]), atomic file replacement via temporary file rename fails under Linux due to locked file inodes.
  2. Environment precedence conflict: when configuration is injected via container environment variables (environment: in Compose or -e), OS environment variables take precedence over .env on startup. Changes saved through the Web UI to the file are effectively overridden and lost on restart.
  3. Container immutability: in containerized and cloud deployments, configuration should be declarative, injected from the outside, and immutable (read-only) at runtime.

This PR makes the service configuration strictly read-only at runtime and completely eliminates .env mutation by the application.

Key Changes

  1. Read-only configuration on backend:

    • Removed Save() and atomicWrite from internal/config/config.go.
    • Removed PUT /api/config endpoint and UpdateRuntimeConfig methods from internal/api/ and internal/app/.
    • Configuration is strictly read-only and accessible via GET /api/config.
  2. Simplified read-only SettingsPanel in Web UI:

    • Converted SettingsPanel.vue from an editable form to a clean, compact key-value display.
    • Added a prominent informational callout block explaining that settings are loaded from environment variables or .env at startup and are immutable at runtime.
    • Organized settings into two clear, compact panels: Network & Access and Workers & Scheduling.
  3. Camoufox HEADLESS configuration:

    • Previously, Camoufox WAA workers were hardcoded to headless mode (Headless: true).
    • Exposed HEADLESS environment variable (defaults to true), allowing visible browser window when set to false for debugging and troubleshooting.
    • Added status indicator in Web UI and documented in .env.example.
  4. Comprehensive ROUTING_STRATEGY documentation:

    • Added clear, detailed descriptions for round-robin (balances load and distributes rate limits across accounts) and fill-first (sticky routing until full or cooling down before falling back) in .env.example, Web UI, and docs.
  5. Support for CAMOUFOX_PATH in .env:

    • Added CAMOUFOX_PATH to recognized .env keys in configKeys so that paths specified in .env are exported to the process environment.

@IllusionOfControl

Copy link
Copy Markdown
Contributor Author

In case of consideration of the proposal, I will make an update in this MR, taking into account my past MR #27

…ents

- Remove runtime modification and saving of .env file
- Remove PUT /api/config endpoint and UpdateRuntimeConfig methods
- Convert Web UI SettingsPanel into a read-only configuration overview
- Expose HEADLESS mode for Camoufox in configuration and .env.example
- Add comprehensive documentation and descriptions for ROUTING_STRATEGY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant