From 98522d5a018a2c738315a5b6b7b92d2946d96783 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 Aug 2025 19:54:31 +0000 Subject: [PATCH] Add Docker documentation and finalize external config implementation Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> --- .gitignore | 4 +++ DOCKER_CONFIG.md | 64 ++++++++++++++++++++++++++++++++++++ Server/config/transport.json | 16 ++++----- 3 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 DOCKER_CONFIG.md diff --git a/.gitignore b/.gitignore index c629877..532a53b 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,7 @@ nunit-*.xml # mac files .DS_Store + +# Configuration files (uncomment to avoid committing development configs) +# config/ +# **/config/ diff --git a/DOCKER_CONFIG.md b/DOCKER_CONFIG.md new file mode 100644 index 0000000..967b82f --- /dev/null +++ b/DOCKER_CONFIG.md @@ -0,0 +1,64 @@ +# Configuration Persistence for Docker + +ShiftScheduler now supports persisting configuration changes in external files, making it suitable for Docker deployments where configuration should survive container rebuilds. + +## How it Works + +Configuration is automatically saved to and loaded from external JSON files in the `config/` directory: + +- `config/shifts.json` - Contains all shift definitions (name, icon, times) +- `config/transport.json` - Contains transport API settings and parameters + +## Behavior + +1. **Startup**: Service reads from external files if they exist, otherwise uses `appsettings.json` defaults +2. **Initial Creation**: If external files don't exist, they're created with current configuration +3. **Updates**: Any configuration changes via the UI are automatically saved to external files +4. **Persistence**: External files persist across application restarts + +## Docker Usage + +### Docker Compose Example + +```yaml +version: '3.8' +services: + shiftscheduler: + build: . + ports: + - "5000:5000" + volumes: + - ./config:/app/config # Mount config directory + environment: + - ASPNETCORE_ENVIRONMENT=Production +``` + +### Folder Structure + +``` +project/ +├── docker-compose.yml +├── config/ # This directory will be created automatically +│ ├── shifts.json # Persisted shift configurations +│ └── transport.json # Persisted transport settings +└── ... +``` + +## Benefits + +- **Persistence**: Configuration survives container rebuilds +- **Backup**: Easy to backup/restore configuration by copying JSON files +- **Version Control**: Configuration files can be committed to source control +- **Multiple Environments**: Different config files for different deployments +- **No Data Loss**: UI changes are automatically preserved + +## Migration + +No migration needed - existing installations will automatically: +1. Create the `config/` directory on next startup +2. Export current configuration to external files +3. Continue using existing settings + +## File Format + +Configuration files use standard JSON format and can be edited directly if needed. Changes take effect after application restart. \ No newline at end of file diff --git a/Server/config/transport.json b/Server/config/transport.json index fde03b0..091505f 100644 --- a/Server/config/transport.json +++ b/Server/config/transport.json @@ -1,10 +1,10 @@ { - "StartStation": "Modified Station", - "EndStation": "Modified End", - "ApiBaseUrl": "http://modified.com/v1", - "SafetyBufferMinutes": 45, - "MinBreakMinutes": 90, - "MaxEarlyArrivalMinutes": 90, - "MaxLateArrivalMinutes": 30, - "CacheDurationDays": 2 + "StartStation": "Zurich", + "EndStation": "Basel", + "ApiBaseUrl": "http://transport.opendata.ch/v1", + "SafetyBufferMinutes": 30, + "MinBreakMinutes": 60, + "MaxEarlyArrivalMinutes": 60, + "MaxLateArrivalMinutes": 15, + "CacheDurationDays": 1 } \ No newline at end of file