Files
bolt-diy/scripts/setup-env.sh
Keoma Wright 56e602b7f4 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
2025-08-24 10:31:23 +00:00

41 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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"