From 3dfc01ec2dba1bc4945b44262c2910a1c8a24bd8 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Mon, 30 Dec 2019 23:07:42 +0300 Subject: [PATCH] fix(upgrade): Fix upgrade instructions and script (#304) --- README.md | 9 +-------- install.sh | 12 ++++++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e73ce6d..2a0267c 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,7 @@ and [Nginx](http://nginx.org/). You'll likely want to add this service to your ` ## Updating Sentry -Updating Sentry using Compose is relatively simple. Just use the following steps to update. Make sure that you have the latest version set in your Dockerfile. Or use the latest version of this repository. - -Use the following steps after updating this repository or your Dockerfile: -```sh -docker-compose build --pull # Build the services again after updating, and make sure we're up to date on patch version -docker-compose run --rm web upgrade # Run new migrations -docker-compose up -d # Recreate the services -``` +The included `install.sh` script is meant to be idempotent and to bring you to the latest version. What this means is you can and should run `install.sh` to upgrade to the latest version available. ## Resources diff --git a/install.sh b/install.sh index 39349bc..742d131 100755 --- a/install.sh +++ b/install.sh @@ -55,8 +55,8 @@ if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then exit -1 fi -# Ensure nothing is working while we install/update -docker-compose stop +# Clean up old stuff and ensure nothing is working while we install/update +docker-compose down --rmi local --remove-orphans echo "" echo "Creating volumes for persistent storage..." @@ -84,6 +84,8 @@ echo "" echo "Building and tagging Docker images..." echo "" # Build the sentry onpremise image first as it is needed for the cron image +docker-compose pull --ignore-pull-failures +docker pull ${SENTRY_IMAGE:-getsentry/sentry:latest} docker-compose build --force-rm web docker-compose build --force-rm echo "" @@ -91,6 +93,7 @@ echo "Docker images built." # Very naively check whether there's an existing sentry-postgres volume and the PG version in it if [[ $(docker volume ls -q --filter name=sentry-postgres) && $(docker run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2>/dev/null) == "9.5" ]]; then + docker volume rm sentry-postgres-new || true # If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume docker run --rm \ -v sentry-postgres:/var/lib/postgresql/9.5/data \ @@ -123,10 +126,11 @@ else docker-compose run --rm web upgrade fi -SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l") +SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l || true") if [ "$SENTRY_DATA_NEEDS_MIGRATION" ]; then echo "Migrating file storage..." - docker run --rm -v sentry-data:/data alpine ash -c \ + # Use the web (Sentry) image so the file owners are kept as sentry:sentry + docker-compose run --rm --entrypoint /bin/bash web -c \ "mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files" fi