Stumbling setting up onpremise with docker

I was trying to follow Installation with Docker and didn’t quite succeed.

  • That document mentions that sentry.conf.py and config.yml [are] ready for customizing, but I’m not sure whether there is anything that must be customized. I changed only system.secret-key.
  • The example command given at The base for running commands will look something like: fails. See https://github.com/getsentry/sentry/pull/5755 . I guess that --detach is the correct option here. (PR merged, thanks!)
  • Starting the Web Service doesn’t. Doing docker logs <mycontainerid> I see: Exception: Error: SENTRY_SECRET_KEY is undefined. I did add the key to config.yml and run make build again:
root@ubuntu-xenial:~/onpremise# grep system.secret config.yml 
# system.secret-key: 'changeme'
system.secret-key: 'h_qu@2w...`

However that didn’t help. I also reset the VM in which I’m installing, configured system.secret-key before the first make build, still no luck. Then I passed the key on the commandline, and finally that worked. The full command was:

docker run   --detach   --link sentry-redis:redis   --link sentry-postgres:postgres --link sentry-smtp:smtp --name sentry-web-01 --publish 9000:9000 --env SENTRY_SECRET_KEY="h_qu@2w..." sentry-onpremise run web

I ran the commands to start the worker and cron images, including all the --link options and the --env option.

Looks good:

root@ubuntu-xenial:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
6a67273ce79d        sentry-onpremise    "/entrypoint.sh run c"   14 minutes ago      Up About a minute   9000/tcp                 sentry-cron
91e6390cf3d6        sentry-onpremise    "/entrypoint.sh run w"   14 minutes ago      Up About a minute   9000/tcp                 sentry-worker-01
33c99c19dc3a        sentry-onpremise    "/entrypoint.sh run w"   20 minutes ago      Up About a minute   0.0.0.0:9000->9000/tcp   sentry-web-01
13fee4265597        tianon/exim4        "entrypoint.sh tini -"   25 minutes ago      Up About a minute   25/tcp                   sentry-smtp
a9961502b0ec        postgres:9.5        "docker-entrypoint.sh"   34 minutes ago      Up About a minute   5432/tcp                 sentry-postgres
a03bac9a0311        redis:3.2-alpine    "docker-entrypoint.sh"   34 minutes ago      Up About a minute   6379/tcp                 sentry-redis

Trying to access the web interface retries endlessly, locally:

root@ubuntu-xenial:~# wget http://localhost:9000/
--2017-07-25 11:20:35--  http://localhost:9000/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:9000... connected.
HTTP request sent, awaiting response... 302 FOUND
Location: http://localhost:9000/auth/login/ [following]
--2017-07-25 11:20:35--  http://localhost:9000/auth/login/
Connecting to localhost (localhost)|127.0.0.1|:9000... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

--2017-07-25 11:20:36--  (try: 2)  http://localhost:9000/auth/login/
Connecting to localhost (localhost)|127.0.0.1|:9000... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

Trying in Firefox via a forwarded port to Sentry in the VM gets a zero-size document:

At this point the sentry-web-01 logs are showing:

...
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 88, in inner
    return func(self, sql, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sentry/db/postgres/base.py", line 39, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ProgrammingError('relation "sentry_projectkey" does not exist\nLINE 1: ...nt", "sentry_projectkey"."rate_limit_window" FROM "sentry_pr...\n                                                             ^\n',)
SQL: SELECT "sentry_projectkey"."id", "sentry_projectkey"."project_id", "sentry_projectkey"."label", "sentry_projectkey"."public_key", "sentry_projectkey"."secret_key", "sentry_projectkey"."roles", "sentry_projectkey"."status", "sentry_projectkey"."date_added", "sentry_projectkey"."rate_limit_count", "sentry_projectkey"."rate_limit_window" FROM "sentry_projectkey" WHERE ("sentry_projectkey"."project_id" = %s  AND "sentry_projectkey"."roles" =  ("sentry_projectkey"."roles" | 1)) LIMIT 1
10.0.2.2 - - [25/Jul/2017:11:22:17 +0000] "GET /auth/login/ HTTP/1.1" 500 0 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0"

The error messages indicate some DB schema mismatch.

As mentioned in the same doc, https://docs.sentry.io/server/installation/docker/ run upgrade first.

I had same problems that you had until I ran the upgrade (except I still don’t know why rebuilding image after added secret key to config.yml does work as expected. I am still passing in env so far).

Here is the docker command:
docker run
–link sentry-redis:redis
–link sentry-postgres:postgres
–link sentry-smtp:smtp
–env SENTRY_SECRET_KEY=‘xxxxxxxxxxxxxxxxxxxxxx’ \
–rm -it sentry-onpremise:latest
upgrade

after that, you will see a new container spun up:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f1949c97c4e sentry-onpremise:latest “/entrypoint.sh up…” 2 hours ago Up 2 hours 9000/tcp frosty_varahamihira

Now try to start the Web Service again(delete existing Web Service container first even it’s not running). You will be able to see http://localhost:9000/ rendered.