fix: resolve .env.local not loading in docker compose
Fixes issue #1827 where Docker Compose wasn't properly loading .env.local file. Problem: - Docker Compose expects .env file for variable substitution but docs say to use .env.local - This caused environment variables to not be loaded in Docker containers Solution: - Updated docker-compose.yaml to load both .env and .env.local files - Created setup-env.sh script to help users sync .env.local to .env - Updated documentation with clear instructions for Docker users - Maintains backward compatibility with existing setups Changes: - Modified docker-compose.yaml to use array syntax for env_file - Added scripts/setup-env.sh helper script - Updated CONTRIBUTING.md and index.md documentation This ensures environment variables work correctly in Docker while maintaining the security best practice of using .env.local for sensitive data. Contributed by: Keoma Wright
This commit is contained in:
41
scripts/setup-env.sh
Executable file
41
scripts/setup-env.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup script for Docker environment variables
|
||||
# This script helps resolve the issue where .env.local is not being loaded in Docker
|
||||
|
||||
echo "🔧 Setting up environment files for Docker..."
|
||||
|
||||
# Check if .env.local exists
|
||||
if [ -f ".env.local" ]; then
|
||||
echo "✅ Found .env.local file"
|
||||
|
||||
# Create symlink or copy to .env for Docker Compose
|
||||
if [ ! -f ".env" ] || [ ".env" -ot ".env.local" ]; then
|
||||
echo "📋 Copying .env.local to .env for Docker Compose compatibility..."
|
||||
cp .env.local .env
|
||||
echo "✅ Environment file synced"
|
||||
else
|
||||
echo "ℹ️ .env file already up to date"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ No .env.local file found"
|
||||
|
||||
# Check if .env.example exists and offer to copy it
|
||||
if [ -f ".env.example" ]; then
|
||||
echo "📋 Found .env.example file"
|
||||
read -p "Would you like to create .env.local from .env.example? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
cp .env.example .env.local
|
||||
cp .env.example .env
|
||||
echo "✅ Created .env.local and .env from .env.example"
|
||||
echo "📝 Please edit .env.local with your API keys"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "✨ Environment setup complete!"
|
||||
echo ""
|
||||
echo "📚 Note: Docker Compose reads both .env and .env.local files"
|
||||
echo " - .env is used for variable substitution in docker-compose.yaml"
|
||||
echo " - .env.local is passed to the container for runtime variables"
|
||||
Reference in New Issue
Block a user