-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support bun-like .env hierarchy in docker compose
- Loading branch information
Showing
4 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# this script extends docker-compose up by supporting .env files in the same way as bun | ||
# see: https://bun.sh/docs/runtime/env#setting-environment-variables | ||
|
||
# Default env file | ||
env_file=".env" | ||
|
||
# Determine which env file to use based on NODE_ENV | ||
if [ "$NODE_ENV" == "production" ]; then | ||
env_file=".env.production" | ||
elif [ "$NODE_ENV" == "development" ]; then | ||
env_file=".env.development" | ||
elif [ "$NODE_ENV" == "test" ]; then | ||
env_file=".env.test" | ||
fi | ||
|
||
# If .env.local exists, use that instead | ||
if [ -f ".env.local" ]; then | ||
env_file=".env.local" | ||
fi | ||
|
||
# Run docker-compose with the selected env file | ||
docker-compose --env-file $env_file up -d |