Skip to content

Commit 1ededd7

Browse files
BYKMaicolBen
authored andcommitted
fix(upgrade): Fix upgrade instructions and script (getsentry#304)
1 parent cc97e6f commit 1ededd7

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@ and [Nginx](http://nginx.org/). You'll likely want to add this service to your `
4141

4242
## Updating Sentry
4343

44-
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.
45-
46-
Use the following steps after updating this repository or your Dockerfile:
47-
```sh
48-
docker-compose build --pull # Build the services again after updating, and make sure we're up to date on patch version
49-
docker-compose run --rm web upgrade # Run new migrations
50-
docker-compose up -d # Recreate the services
51-
```
44+
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.
5245

5346
## Resources
5447

install.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then
5555
exit -1
5656
fi
5757

58-
# Ensure nothing is working while we install/update
59-
docker-compose stop
58+
# Clean up old stuff and ensure nothing is working while we install/update
59+
docker-compose down --rmi local --remove-orphans
6060

6161
echo ""
6262
echo "Creating volumes for persistent storage..."
@@ -84,13 +84,16 @@ echo ""
8484
echo "Building and tagging Docker images..."
8585
echo ""
8686
# Build the sentry onpremise image first as it is needed for the cron image
87+
docker-compose pull --ignore-pull-failures
88+
docker pull ${SENTRY_IMAGE:-getsentry/sentry:latest}
8789
docker-compose build --force-rm web
8890
docker-compose build --force-rm
8991
echo ""
9092
echo "Docker images built."
9193

9294
# Very naively check whether there's an existing sentry-postgres volume and the PG version in it
9395
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
96+
docker volume rm sentry-postgres-new || true
9497
# If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume
9598
docker run --rm \
9699
-v sentry-postgres:/var/lib/postgresql/9.5/data \
@@ -123,10 +126,11 @@ else
123126
docker-compose run --rm web upgrade
124127
fi
125128

126-
SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l")
129+
SENTRY_DATA_NEEDS_MIGRATION=$(docker run --rm -v sentry-data:/data alpine ash -c "[ ! -d '/data/files' ] && ls -A1x /data | wc -l || true")
127130
if [ "$SENTRY_DATA_NEEDS_MIGRATION" ]; then
128131
echo "Migrating file storage..."
129-
docker run --rm -v sentry-data:/data alpine ash -c \
132+
# Use the web (Sentry) image so the file owners are kept as sentry:sentry
133+
docker-compose run --rm --entrypoint /bin/bash web -c \
130134
"mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files"
131135
fi
132136

0 commit comments

Comments
 (0)