[PR #29845] feat(docker): add environment variables synchronization tool #32579

Closed
opened 2026-02-21 20:51:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/29845

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This PR introduces a new environment variables synchronization tool (dify-env-sync.sh) to help users safely update their .env files when upgrading Dify or pulling latest changes from .env.example.

resolve https://github.com/langgenius/dify/issues/29868

Problem: When upgrading Dify, users often struggle to keep their .env files up-to-date with new variables from .env.example without losing their custom configurations. Manual synchronization is error-prone and time-consuming.

Solution: An automated bash script that:

  • Preserves all existing custom values in .env
  • Adds new environment variables from .env.example
  • Creates timestamped backups before making changes
  • Detects removed variables for manual cleanup
  • Provides detailed diff analysis with value change insights

Key Features:

  • Safe one-way synchronization from .env.example to .env
  • Robust error handling and comprehensive logging

Screenshots

Before After

# Database configuration
DB_HOST=db
DB_USERNAME=postgres
DB_PASSWORD=my_custom_password

# Custom Lindorm settings
LINDORM_URL=http://lindorm:30070
LINDORM_USERNAME=lindorm

# File upload limits
UPLOAD_AUDIO_FILE_SIZE_LIMIT=70

# Code execution limits
CODE_MAX_STRING_LENGTH=80000

# Missing: AMPLITUDE_API_KEY
# Missing: NEW_FEATURE_FLAG

# Database configuration
DB_HOST=db
DB_USERNAME=postgres
DB_PASSWORD=my_custom_password

# Custom Lindorm settings
LINDORM_URL=http://lindorm:30070
LINDORM_USERNAME=lindorm

# File upload limits
UPLOAD_AUDIO_FILE_SIZE_LIMIT=70

# Code execution limits
CODE_MAX_STRING_LENGTH=80000

# Newly added from .env.example
AMPLITUDE_API_KEY=
NEW_FEATURE_FLAG=false
VECTOR_STORE_CONFIG={"timeout": 30}

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/29845 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary This PR introduces a new environment variables synchronization tool (`dify-env-sync.sh`) to help users safely update their `.env` files when upgrading Dify or pulling latest changes from `.env.example`. resolve https://github.com/langgenius/dify/issues/29868 **Problem:** When upgrading Dify, users often struggle to keep their `.env` files up-to-date with new variables from `.env.example` without losing their custom configurations. Manual synchronization is error-prone and time-consuming. **Solution:** An automated bash script that: - Preserves all existing custom values in `.env` - Adds new environment variables from `.env.example` - Creates timestamped backups before making changes - Detects removed variables for manual cleanup - Provides detailed diff analysis with value change insights **Key Features:** - Safe one-way synchronization from `.env.example` to `.env` - Robust error handling and comprehensive logging ## Screenshots | Before | After | |--------|-------| | <br/># Database configuration<br/>DB_HOST=db<br/>DB_USERNAME=postgres<br/>DB_PASSWORD=my_custom_password<br/><br/># Custom Lindorm settings<br/>LINDORM_URL=http://lindorm:30070<br/>LINDORM_USERNAME=lindorm<br/><br/># File upload limits<br/>UPLOAD_AUDIO_FILE_SIZE_LIMIT=70<br/><br/># Code execution limits<br/>CODE_MAX_STRING_LENGTH=80000<br/><br/># Missing: AMPLITUDE_API_KEY<br/># Missing: NEW_FEATURE_FLAG<br/> | <br/># Database configuration<br/>DB_HOST=db<br/>DB_USERNAME=postgres<br/>DB_PASSWORD=my_custom_password<br/><br/># Custom Lindorm settings<br/>LINDORM_URL=http://lindorm:30070<br/>LINDORM_USERNAME=lindorm<br/><br/># File upload limits<br/>UPLOAD_AUDIO_FILE_SIZE_LIMIT=70<br/><br/># Code execution limits<br/>CODE_MAX_STRING_LENGTH=80000<br/><br/># Newly added from .env.example<br/>AMPLITUDE_API_KEY=<br/>NEW_FEATURE_FLAG=false<br/>VECTOR_STORE_CONFIG={"timeout": 30}<br/>| ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:51:40 -05:00
yindo closed this issue 2026-02-21 20:51:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32579