Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom DotEnv file #1113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ target/
# https://docs.docker.com/compose/extends/
docker-compose.override.yml

# https://docs.docker.com/compose/environment-variables/#using-the---env-file--option
.env.custom

*.tar
data/
.vscode/tags
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ Official bootstrap for running your own [Sentry](https://sentry.io/) with [Docke

## Setup

### Customize DotEnv (.env) file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to lift this part up into https://develop.sentry.dev/self-hosted/#configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. But I guess it makes sense to leave this information here as well.

I've created a pull request for the documentation change: getsentry/develop#460


Environment specific configurations can be done in the `.env.custom` file. It will be located in the root directory of the Sentry installation.

By default, there exists no `.env.custom` file. In this case, you can manually add this file by copying the `.env` file to a new `.env.custom` file and adjust your settings in the `.env.custom` file.

Please keep in mind to check the `.env` file for changes, when you perform an upgrade of Sentry, so that you can adjust your `.env.custom` accordingly, if required.

### Installation

To get started with all the defaults, simply clone the repo and run `./install.sh` in your local check-out. Sentry uses Python 3 by default since December 4th, 2020 and Sentry 21.1.0 is the last version to support Python 2.

During the install, a prompt will ask if you want to create a user account. If you require that the install not be blocked by the prompt, run `./install.sh --no-user-prompt`.
Expand Down
9 changes: 7 additions & 2 deletions install/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ else
cd "$(dirname $0)" # assume we're a test script or some such
fi

_ENV="$(realpath ../.env)"
# Allow `.env` overrides using the `.env.custom` file
if [[ -f "../.env.custom" ]]; then
_ENV="$(realpath ../.env.custom)"
else
_ENV="$(realpath ../.env)"
fi

# Read .env for default values with a tip o' the hat to https://stackoverflow.com/a/59831605/90297
t=$(mktemp) && export -p > "$t" && set -a && . $_ENV && set +a && . "$t" && rm "$t" && unset t
Expand All @@ -26,7 +31,7 @@ else
fi

dc_base="$(docker compose version &> /dev/null && echo 'docker compose' || echo 'docker-compose')"
dc="$dc_base --ansi never"
dc="$dc_base --ansi never --env-file ${_ENV}"
dcr="$dc run --rm"

# A couple of the config files are referenced from other subscripts, so they
Expand Down
4 changes: 4 additions & 0 deletions install/wrap-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ else
echo ""
echo "You're all done! Run the following command to get Sentry running:"
echo ""
if [[ "${_ENV}" =~ ".env.custom" ]]; then
echo " $dc_base --env-file ${_ENV} up -d"
else
echo " $dc_base up -d"
fi
echo ""
echo "-----------------------------------------------------------------"
echo ""
Expand Down