feat(sentry10): Make on-premise work for Sentry 10 (#220)
This commit is contained in:
68
install.sh
68
install.sh
@ -2,9 +2,12 @@
|
||||
set -e
|
||||
|
||||
MIN_DOCKER_VERSION='17.05.0'
|
||||
MIN_COMPOSE_VERSION='1.17.0'
|
||||
MIN_RAM=3072 # MB
|
||||
ENV_FILE='.env'
|
||||
MIN_COMPOSE_VERSION='1.19.0'
|
||||
MIN_RAM=2400 # MB
|
||||
|
||||
SENTRY_CONFIG_PY='sentry/sentry.conf.py'
|
||||
SENTRY_CONFIG_YML='sentry/config.yml'
|
||||
SENTRY_EXTRA_REQUIREMENTS='sentry/requirements.txt'
|
||||
|
||||
DID_CLEAN_UP=0
|
||||
# the cleanup function will be the exit point
|
||||
@ -27,6 +30,16 @@ RAM_AVAILABLE_IN_DOCKER=$(docker run --rm busybox free -m 2>/dev/null | awk '/Me
|
||||
# Compare dot-separated strings - function below is inspired by https://stackoverflow.com/a/37939589/808368
|
||||
function ver () { echo "$@" | awk -F. '{ printf("%d%03d%03d", $1,$2,$3); }'; }
|
||||
|
||||
# Thanks to https://stackoverflow.com/a/25123013/90297 for the quick `sed` pattern
|
||||
function ensure_file_from_example {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$1 already exists, skipped creation."
|
||||
else
|
||||
echo "Creating $1..."
|
||||
cp -n $(echo "$1" | sed 's/\.[^.]*$/.example&/') "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $(ver $DOCKER_VERSION) -lt $(ver $MIN_DOCKER_VERSION) ]; then
|
||||
echo "FAIL: Expected minimum Docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
|
||||
exit -1
|
||||
@ -42,32 +55,36 @@ if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then
|
||||
exit -1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ensure_file_from_example $SENTRY_CONFIG_PY
|
||||
ensure_file_from_example $SENTRY_CONFIG_YML
|
||||
ensure_file_from_example $SENTRY_EXTRA_REQUIREMENTS
|
||||
|
||||
echo ""
|
||||
echo "Creating volumes for persistent storage..."
|
||||
echo "Created $(docker volume create --name=sentry-data)."
|
||||
echo "Created $(docker volume create --name=sentry-postgres)."
|
||||
echo ""
|
||||
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
echo "$ENV_FILE already exists, skipped creation."
|
||||
else
|
||||
echo "Creating $ENV_FILE..."
|
||||
cp -n .env.example "$ENV_FILE"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Building and tagging Docker images..."
|
||||
echo ""
|
||||
docker-compose build
|
||||
echo ""
|
||||
echo "Docker images built."
|
||||
echo "Created $(docker volume create --name=sentry-redis)."
|
||||
echo "Created $(docker volume create --name=sentry-zookeeper)."
|
||||
echo "Created $(docker volume create --name=sentry-kafka)."
|
||||
echo "Created $(docker volume create --name=sentry-clickhouse)."
|
||||
echo "Created $(docker volume create --name=sentry-symbolicator)."
|
||||
|
||||
echo ""
|
||||
echo "Generating secret key..."
|
||||
# This is to escape the secret key to be used in sed below
|
||||
SECRET_KEY=$(docker-compose run --rm web config generate-secret-key 2> /dev/null | tail -n1 | sed -e 's/[\/&]/\\&/g')
|
||||
sed -i -e 's/^SENTRY_SECRET_KEY=.*$/SENTRY_SECRET_KEY='"$SECRET_KEY"'/' $ENV_FILE
|
||||
echo "Secret key written to $ENV_FILE"
|
||||
SECRET_KEY=$(head /dev/urandom | tr -dc "a-z0-9@#%^&*(-_=+)" | head -c 50 | sed -e 's/[\/&]/\\&/g')
|
||||
sed -i -e 's/^system.secret-key:.*$/system.secret-key: '"'$SECRET_KEY'"'/' $SENTRY_CONFIG_YML
|
||||
echo "Secret key written to $SENTRY_CONFIG_YML"
|
||||
|
||||
echo ""
|
||||
echo "Building and tagging Docker images..."
|
||||
echo ""
|
||||
# Build the sentry onpremise image first as it is needed for the cron image
|
||||
docker-compose build --force-rm web
|
||||
docker-compose build --force-rm
|
||||
echo ""
|
||||
echo "Docker images built."
|
||||
|
||||
echo ""
|
||||
echo "Setting up database..."
|
||||
@ -83,11 +100,18 @@ else
|
||||
docker-compose run --rm web upgrade
|
||||
fi
|
||||
|
||||
echo "Boostrapping Snuba..."
|
||||
docker-compose up -d kafka redis clickhouse
|
||||
until $(docker-compose run --rm clickhouse clickhouse-client -h clickhouse --query="SHOW TABLES;" | grep -q sentry_local); do
|
||||
docker-compose run --rm snuba-api bootstrap --force || true;
|
||||
done;
|
||||
echo ""
|
||||
|
||||
cleanup
|
||||
|
||||
echo ""
|
||||
echo "----------------"
|
||||
echo "You're all done! Run the following command get Sentry running:"
|
||||
echo "You're all done! Run the following command to get Sentry running:"
|
||||
echo ""
|
||||
echo " docker-compose up -d"
|
||||
echo ""
|
||||
|
Reference in New Issue
Block a user