brettkromkamp / contextualise

Contextualise is an effective tool particularly suited for organising information-heavy projects and activities consisting of unstructured and widely diverse data and information resources
https://contextualise.dev/
MIT License
1.05k stars 44 forks source link

Issues with bringing the app up with docker #67

Closed stratosgear closed 4 years ago

stratosgear commented 4 years ago

I just wanted to quickly test out the dockerized version of the app and I came across two issues. I solved the first but did not want to invest more time on the other.

First one was an error with postgres:

$ docker logs contextualise_db_1
Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

       You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
       connections without a password. This is *not* recommended.

       See PostgreSQL documentation about "trust":
       https://www.postgresql.org/docs/current/auth-trust.html

That fix was easy, I just added an environment section to the db services in docker-compose.yml:

  db:
    image: postgres:alpine
    volumes:
      - "./sql_init.sh:/docker-entrypoint-initdb.d/init_user_db.sh:ro"
      - "pg_data:/var/lib/postgresql/data"
    environment:
      - POSTGRES_PASSWORD=postgres

But then upon login in I got another:

[2020-05-11 09:34:24,629] ERROR in app: Exception on /maps/ [GET]
Traceback (most recent call last):
  File "/root/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/root/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/root/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/root/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/root/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/root/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/root/.local/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/usr/src/app/contextualise/map.py", line 24, in index
    maps = topic_store.get_topic_maps(current_user.id)
  File "/root/.local/lib/python3.8/site-packages/topicdb/core/store/topicstore.py", line 1579, in get_topic_maps
    cursor.execute(sql, (user_identifier,))
  File "/root/.local/lib/python3.8/site-packages/psycopg2/extras.py", line 143, in execute
    return super(DictCursor, self).execute(query, vars)
psycopg2.errors.UndefinedTable: relation "topicdb.user_topicmap" does not exist
LINE 13:             JOIN topicdb.user_topicmap ON topicdb.topicmap.i...
                          ^

As this seems to be more application specific I did not delve any further.

brettkromkamp commented 4 years ago

@stratosgear I see the problem. The database structure has changed since the Docker support was added and the https://github.com/brettkromkamp/contextualise/blob/master/sql_init.sh has not been updated accordingly. I'll fix that specific problem later today.

brettkromkamp commented 4 years ago

@stratosgear Should be fixed with this commit: https://github.com/brettkromkamp/contextualise/commit/72dcff1367096dfccd70952c3aa6ba07599447fb

Could you checkout the master branch and try again (I have not incorporated your suggested fix - could you submit a PR to address that specific issue)?

stratosgear commented 4 years ago

Yes the new sql_init.sh fixes the issue.

Had to:

before the changes would take effect, but they did right after I did the above.

Thanks!

brettkromkamp commented 4 years ago

My Docker knowledge is sketchy at best. Any suggestions for improvements are more than welcome ;)

stratosgear commented 4 years ago

Nothing wrong with the steps I took to fix the errors, there is nothing to improve here. I just listed the steps as a convenience to anyone else that came across the same issue.