Albireo icon indicating copy to clipboard operation
Albireo copied to clipboard

How to set up with docker?

Open Lyken17 opened this issue 6 years ago • 5 comments

After docker build ., the image was successfully built. However, when I typed next instructions, following error occurred.

02:58 Albireo (master) ✗ docker run --rm -it -v "latest:/albireo" -p 127.0.0.1:5000:5000 albireo
 * Starting PostgreSQL 9.3 database server                                                                                                                                                         [ OK ]
python: can't open file '/albireo/server.py': [Errno 2] No such file or directory

My environments:

✘ 02:58 Albireo (master) ✗ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
albireo             latest              112a08e5bc6b        3 minutes ago       815MB
nextcloud           latest              6cec9cff80aa        2 weeks ago         593MB
ubuntu              14.04               3b853789146f        3 weeks ago         223MB
02:58 Albireo (master) ✗ ls
CHANGELOG.md        README.md           alembic             appd.py             domain              import.py           rpc                 taskrunner          utils
Dockerfile          Scheduler.py        alembic.ini.example config              download_adapter    requirements.txt    server.py           templates           web_hook
LICENSE             __init__.py         apiary.apib         config.yml          feed_scanner        routes              service             tools.py

Lyken17 avatar May 06 '18 21:05 Lyken17

It seems that the CMD direction isn't correct. CMD ["bash", "-c", "/etc/init.d/postgresql start && python /albireo/server.py"] the last part should be python /home/albireo/server.py

lordfriend avatar May 07 '18 07:05 lordfriend

@HerringtonDarkholme How did you build your docker image to run anyway? Is that path really runnable?

lordfriend avatar May 07 '18 07:05 lordfriend

Sorry for the confusion. In our production environment, We use a more complex docker-compose configuration to run this project in several separate containers. And my development environment doesn't use docker because I already setup the environment before the docker file is merged to my repository.

lordfriend avatar May 07 '18 07:05 lordfriend

Thanks for your response.

I fixed the directory and some other issues. Now I can run docker run , however, the flask server still has errors...

https://github.com/Lyken17/Albireo/blob/master/Dockerfile

✘ 12:35 Albireo (master) ✗ docker run --rm -it -v "latest:/albireo" -p 127.0.0.1:5000:5000 albireo

 * Starting PostgreSQL 9.3 database server                                                  [ OK ]
2018/05/07 07:36:04 http:97 create session storage dir ./.session successfully
2018/05/07 07:36:05 sentry:34 no sentry.yml exists
 * Serving Flask app "server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
2018/05/07 07:36:05 _internal:88  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
2018/05/07 07:36:08 server:94 404 Not Found: The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1791, in dispatch_request
    self.raise_routing_exception(req)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1774, in raise_routing_exception
    raise request.routing_exception
NotFound: 404 Not Found: The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.
2018/05/07 07:36:08 app:1761 Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1816, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1833, in finalize_request
    response = self.process_response(response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2114, in process_response
    self.session_interface.save_session(self, ctx.session, response)
  File "/home/albireo/utils/flask_sessions.py", line 76, in save_session
    saved_session = db_session.query(ServerSession).filter(ServerSession.session_id == sid).first()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2825, in first
    ret = list(self[0:1])
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2617, in __getitem__
    return list(res)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2925, in __iter__
    return self._execute_and_instances(context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2948, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
ProgrammingError: (psycopg2.ProgrammingError) relation "server_session" does not exist
LINE 2: FROM server_session
             ^
 [SQL: 'SELECT server_session.id AS server_session_id, server_session.session_id AS server_session_session_id, server_session.data AS server_session_data, server_session.expiry AS server_session_expiry \nFROM server_session \nWHERE server_session.session_id = %(session_id_1)s \n LIMIT %(param_1)s'] [parameters: {'session_id_1': '345384f3-be48-4ec6-9dfb-8e23d715a71e', 'param_1': 1}] (Background on this error at: http://sqlalche.me/e/f405)
2018/05/07 07:36:08 server:94 (psycopg2.ProgrammingError) relation "server_session" does not exist
LINE 2: FROM server_session
             ^
 [SQL: 'SELECT server_session.id AS server_session_id, server_session.session_id AS server_session_session_id, server_session.data AS server_session_data, server_session.expiry AS server_session_expiry \nFROM server_session \nWHERE server_session.session_id = %(session_id_1)s \n LIMIT %(param_1)s'] [parameters: {'session_id_1': '345384f3-be48-4ec6-9dfb-8e23d715a71e', 'param_1': 1}] (Background on this error at: http://sqlalche.me/e/f405)

Lyken17 avatar May 07 '18 07:05 Lyken17

Had you run the initialization?

# /etc/init.d/postgresql start && python tools.py --db-init && python tools.py --user-add admin 1234 && python tools.py --user-promote admin 3

python tools.py --db-init must be run for the first time to create database tables.

However, the root should not be accessible by default. all API can be found in http://docs.albireo.apiary.io/

You can also setup the web client to test your server.

lordfriend avatar May 07 '18 07:05 lordfriend