diff --git a/.travis.yml b/.travis.yml index 243de20..07a67bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ language: bash services: docker env: - SENTRY_IMAGE=sentry:9.1.2 - - SENTRY_IMAGE=getsentry/sentry:git + - SENTRY_IMAGE=getsentry/sentry:latest script: - ./install.sh - docker-compose run --rm web createuser --superuser --email test@sentry.io --password test123TEST - docker-compose up -d - timeout 60 bash -c 'until $(curl -Isf -o /dev/null http://localhost:9000); do printf '.'; sleep 0.5; done' - ./test.sh diff --git a/Dockerfile b/Dockerfile index 50a59ea..0a3dae5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1 @@ -ARG SENTRY_IMAGE -FROM ${SENTRY_IMAGE}-onbuild +FROM ${SENTRY_IMAGE:-sentry:9.1.2}-onbuild diff --git a/docker-compose.yml b/docker-compose.yml index 20d688c..18cee6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,69 +1,67 @@ # NOTE: This docker-compose.yml is meant to be just an example of how # you could accomplish this on your own. It is not intended to work in # all use-cases and must be adapted to fit your needs. This is merely # a guideline. # See docs.getsentry.com/on-premise/server/ for full # instructions version: '3.4' x-defaults: &defaults restart: unless-stopped build: context: . - args: - SENTRY_IMAGE: ${SENTRY_IMAGE} depends_on: - redis - postgres - memcached - smtp env_file: .env environment: SENTRY_MEMCACHED_HOST: memcached SENTRY_REDIS_HOST: redis SENTRY_POSTGRES_HOST: postgres SENTRY_EMAIL_HOST: smtp volumes: - sentry-data:/var/lib/sentry/files services: smtp: restart: unless-stopped image: tianon/exim4 memcached: restart: unless-stopped image: memcached:1.5-alpine redis: restart: unless-stopped image: redis:3.2-alpine postgres: restart: unless-stopped image: postgres:9.5 volumes: - sentry-postgres:/var/lib/postgresql/data web: <<: *defaults ports: - '9000:9000' cron: <<: *defaults command: run cron worker: <<: *defaults command: run worker volumes: sentry-data: external: true sentry-postgres: external: true diff --git a/install.sh b/install.sh index d3af603..c9fd564 100755 --- a/install.sh +++ b/install.sh @@ -1,101 +1,93 @@ #!/usr/bin/env bash set -e -LATEST_STABLE_SENTRY_IMAGE='sentry:9.1.2' - MIN_DOCKER_VERSION='17.05.0' MIN_COMPOSE_VERSION='1.17.0' MIN_RAM=3072 # MB ENV_FILE='.env' DID_CLEAN_UP=0 # the cleanup function will be the exit point cleanup () { if [ "$DID_CLEAN_UP" -eq 1 ]; then return 0; fi echo "Cleaning up..." docker-compose down &> /dev/null DID_CLEAN_UP=1 } trap cleanup ERR INT TERM echo "Checking minimum requirements..." DOCKER_VERSION=$(docker version --format '{{.Server.Version}}') COMPOSE_VERSION=$(docker-compose --version | sed 's/docker-compose version \(.\{1,\}\),.*/\1/') RAM_AVAILABLE_IN_DOCKER=$(docker run --rm busybox free -m 2>/dev/null | awk '/Mem/ {print $2}'); # Function below is inspired by https://stackoverflow.com/a/29394504/90297 function ver { printf "%03d%03d%03d%03d" $(echo "$1" | sed 's/^0*\([0-9]\+\)\.0*\([0-9]\+\)\.0*\([0-9]\+\).*/\1 \2 \3/' | head -n 3 ); } 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 fi if [ $(ver $COMPOSE_VERSION) -lt $(ver $MIN_COMPOSE_VERSION) ]; then echo "FAIL: Expected minimum docker-compose version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION" exit -1 fi if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then echo "FAIL: Expected minimum RAM available to Docker to be $MIN_RAM MB but found $RAM_AVAILABLE_IN_DOCKER MB" exit -1 fi 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 -if [ -z $SENTRY_IMAGE ]; then - echo "" - echo "\$SENTRY_IMAGE not set, using latest stable: $LATEST_STABLE_SENTRY_IMAGE"; - export SENTRY_IMAGE=$LATEST_STABLE_SENTRY_IMAGE -fi - echo "" echo "Building and tagging Docker images..." echo "" docker-compose build echo "" echo "Docker images built." 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" echo "" echo "Setting up database..." if [ $CI ]; then docker-compose run --rm web upgrade --noinput echo "" echo "Did not prompt for user creation due to non-interactive shell." echo "Run the following command to create one yourself (recommended):" echo "" echo " docker-compose run --rm web createuser" echo "" else docker-compose run --rm web upgrade fi cleanup echo "" echo "----------------" echo "You're all done! Run the following command get Sentry running:" echo "" echo " docker-compose up -d" echo ""