Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker compose doesn't pass cli arguments #65

Closed
zeratax opened this issue May 27, 2021 · 14 comments
Closed

docker compose doesn't pass cli arguments #65

zeratax opened this issue May 27, 2021 · 14 comments

Comments

@zeratax
Copy link
Owner

zeratax commented May 27, 2021

sorry to re-open this issue. But now seems that the version on pip updated as well. So I got my version updated today and it produces the same errors (regardless of pip or docker image directly)

registration            | 2021-05-26T14:20:49.003879113Z Usage: matrix-registration [OPTIONS] COMMAND [ARGS]...
registration            | 2021-05-26T14:20:49.003935786Z 
registration            | 2021-05-26T14:20:49.003952889Z   a token based matrix registration app
registration            | 2021-05-26T14:20:49.003966510Z 
registration            | 2021-05-26T14:20:49.003979523Z Options:
registration            | 2021-05-26T14:20:49.003992439Z   --config-path TEXT  specifies the config file to be used
registration            | 2021-05-26T14:20:49.004005534Z   --version           Show the flask version
registration            | 2021-05-26T14:20:49.004017721Z   -h, --help          Show this message and exit.

my command in docker-compose looks like this

[...]
volumes:
            - "./configs/synapse-registration/config.yaml:/etc/config.yaml:ro"
            - "./configs/synapse-registration/register.html:/usr/local/lib/python3.9/site-packages/matrix_registration/templates/register.html:ro"
            - "./data/matrix-registration/:/data/"
command: /bin/sh -c 'matrix-registration --config-path /etc/config.yaml serve'
[...]

so atm matrix-registration is completly broken for me

The only way that works for me is to change my Dockerfile for the build to install matrix-registration==0.8.0 from pip

Originally posted by @jahlives in #64 (comment)

@zeratax
Copy link
Owner Author

zeratax commented May 27, 2021

hmm so afaik this help page only appears if no arguments are passed or the -h/--help argument.

otherwise it should look like this, even if only the --config-path is being set:

Usage: matrix-registration [OPTIONS] COMMAND [ARGS]...
Try 'matrix-registration -h' for help.

Error: Missing command.

You're command looks correct though, but i'm not that familiar with docker compose

@zeratax zeratax changed the title docker doesn't pass arguments docker compose doesn't pass cli arguments May 27, 2021
@jahlives
Copy link

jahlives commented May 28, 2021

@zeratax
Could hardly imagine that the arguments are not passed, as the very same command does properly work with matrix-registration v 0.8.0 and I have many docker setups (compose) which use command like the above and there is no problem

@jahlives
Copy link

weird is the following message from logs

registration            | 2021-05-28T07:25:05.547871948Z Usage: matrix-registration [OPTIONS] COMMAND [ARGS]...
registration            | 2021-05-28T07:25:05.547940420Z Try 'matrix-registration -h' for help.
registration            | 2021-05-28T07:25:05.547953560Z 
registration            | 2021-05-28T07:25:05.547962189Z Error: No such command 'matrix-registration'.

first claims wrong (missing) params then claiming command does not exist at all???

@jahlives
Copy link

@zeratax

regarding the image: I should have used docker inspect earlier. Seems the image has an entrypoint

 "Entrypoint": [
                "/nix/store/y611r8b86zv0l2r2xnlf408j718f62xl-python3.8-matrix-registration/bin/matrix-registration",
                "--config-path=/data/config.yaml"
            ],

so my command doubled ;-) I'd recommend to remove the --config-path from entrypoint or else it cannot be specified via cli in command.
Still having an issue with the latest version from pip, according to error there is something missing in my config.yaml

AttributeError: 'Config' object has no attribute 'client_redirect'

currently back to 0.8.0 from pip, will try again the latest version and fix the config later today

@jahlives
Copy link

jahlives commented May 28, 2021

okay it works now with latest version from pip. Had to change config.yaml
As for reasons above I cannot use the image. But also with version from pip I have two open "issues"

  1. client_redirect dos NOT redirect to given url. Instead after register it redirects to register page again
  2. not sure that -m when creating a token does what it should. Registered 3 test users with that token but api/token still shows me its used once only

@zeratax
Copy link
Owner Author

zeratax commented May 28, 2021

it will use the last provided --config-path. so you should be able to just overwrite it

@jahlives
Copy link

if I try it with your image and overwrite with the following command

"Cmd": [
                "matrix-registration",
                "--config-path",
                "/etc/config.yaml",
                "serve"
            ],

I still get

registration            | 2021-05-28T11:32:30.542062146Z Usage: matrix-registration [OPTIONS] COMMAND [ARGS]...
registration            | 2021-05-28T11:32:30.542109005Z Try 'matrix-registration -h' for help.
registration            | 2021-05-28T11:32:30.542118073Z 
registration            | 2021-05-28T11:32:30.542125135Z Error: No such command 'matrix-registration'.
registration            | 2021-05-28T11:32:41.920007513Z Usage: matrix-registration [OPTIONS] COMMAND [ARGS]...
registration            | 2021-05-28T11:32:41.920069286Z Try 'matrix-registration -h' for help.
registration            | 2021-05-28T11:32:41.920086826Z 
registration            | 2021-05-28T11:32:41.920100459Z Error: No such command 'matrix-registration'.

but anyway that's okay with me as I just can use the latest version from pip and with that it works as expected

@zeratax
Copy link
Owner Author

zeratax commented May 28, 2021

no I mean can't you just do:

"Cmd": [
  "--config-path",
  "/etc/config.yaml",
  "serve"
],

that should result in:

$ /nix/store/y611r8b86zv0l2r2xnlf408j718f62xl-python3.8-matrix-registration/bin/matrix-registration \
  --config-path /data/config.yaml \
  --config-path /etc/config.yaml \
  serve

where only the last config-path should be used

@jahlives
Copy link

@zeratax
tried that which results in the following process being fired up

/nix/store/qy5z9gcld7dljm4i5hj3z8a9l6p37y81-python3-3.8.8/bin/python3.8 /nix/store/y611r8b86zv0l2r2xnlf408j718f62xl-python3.8-matrix-registration/bin/.matrix-registration-wrapped --config-path=/data/config.yaml --config-path /etc/config.yaml serve

but then it throws exceptions that the db cannot be opened

registration            | 2021-05-29T12:45:17.137905524Z Traceback (most recent call last):
registration            | 2021-05-29T12:45:17.137970719Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2338, in _wrap_pool_connect
registration            | 2021-05-29T12:45:17.137987552Z     return fn()
registration            | 2021-05-29T12:45:17.137995117Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 364, in connect
registration            | 2021-05-29T12:45:17.138002701Z     return _ConnectionFairy._checkout(self)
registration            | 2021-05-29T12:45:17.138009755Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
registration            | 2021-05-29T12:45:17.138017387Z     fairy = _ConnectionRecord.checkout(pool)
registration            | 2021-05-29T12:45:17.138024434Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
registration            | 2021-05-29T12:45:17.138031856Z     rec = pool._do_get()
registration            | 2021-05-29T12:45:17.138038726Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 239, in _do_get
registration            | 2021-05-29T12:45:17.138046129Z     return self._create_connection()
registration            | 2021-05-29T12:45:17.138053047Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
registration            | 2021-05-29T12:45:17.138060454Z     return _ConnectionRecord(self)
registration            | 2021-05-29T12:45:17.138067311Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 440, in __init__
registration            | 2021-05-29T12:45:17.138074679Z     self.__connect(first_connect_check=True)
registration            | 2021-05-29T12:45:17.138081592Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 661, in __connect
registration            | 2021-05-29T12:45:17.138088986Z     pool.logger.debug("Error on connect(): %s", e)
registration            | 2021-05-29T12:45:17.138095986Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
registration            | 2021-05-29T12:45:17.138103421Z     compat.raise_(
registration            | 2021-05-29T12:45:17.138110248Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
registration            | 2021-05-29T12:45:17.138117597Z     raise exception
registration            | 2021-05-29T12:45:17.138126212Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
registration            | 2021-05-29T12:45:17.138134089Z     connection = pool._invoke_creator(self)
registration            | 2021-05-29T12:45:17.138141083Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
registration            | 2021-05-29T12:45:17.138148523Z     return dialect.connect(*cargs, **cparams)
registration            | 2021-05-29T12:45:17.138161494Z   File "/nix/store/pw7vpy2x39sc50ydmqf2klqaymi51cqf-python3.8-SQLAlchemy-1.3.19/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 493, in connect
registration            | 2021-05-29T12:45:17.138169981Z     return self.dbapi.connect(*cargs, **cparams)
registration            | 2021-05-29T12:45:17.138177044Z sqlite3.OperationalError: unable to open database file

guess it tries the /data path to find the db (from first --config-path)

@zeratax
Copy link
Owner Author

zeratax commented May 29, 2021

it definitely shouldn't. the db is handled like everything else:

$ grep db configA.yaml
db: 'sqlite:///{cwd}dbA.sqlite3'
$ grep db configB.yaml
db: 'sqlite:///{cwd}dbB.sqlite3'
$ matrix-registration --config-path=configA.yaml --config-path=configB.yaml generate
UserColonyTaboo
$ ls db*
dbB.sqlite3

Here the first config-path argument has absolutely no effect.

Are you sure there isn't just a mistake with your config file? sqlalchemy expects an absolute path, so if you want to do a relative path it should look like this

db: 'sqlite:///{cwd}db.sqlite3'

where cwd will be replaced by the current working directory

@jahlives
Copy link

@zeratax

I have the following three mounts in my docker-compose

        volumes:
            - "./configs/synapse-registration/register.html:/usr/local/lib/python3.9/site-packages/matrix_registration/templates/register.html:ro"
            - "./data/matrix-registration/:/data/"
            - "./configs/synapse-registration/config.yaml:/etc/config.yaml:ro"

and config.yaml defines db as db: 'sqlite:///{cwd}/data/db.sqlite3'
If I use this command command: ["--config-path","/etc/config.yaml","serve"] together with the image it throws the shown exceptions.

@zeratax
Copy link
Owner Author

zeratax commented Jun 2, 2021

okay sorry the documentation here is wrong and idk how I didn't notice this earlier, but the config file is read in the docker environment so the db isn't in {cwd}/data/db.sqlite3, but /data/db.sqlite3

so it should be:

db: 'sqlite:////data/db.sqlite3'

@jahlives
Copy link

jahlives commented Jun 8, 2021

@zeratax
tried that but still same exceptions. Tried with 3 and 4 / although I think 3 / should be correct. Anyway the pip version works perfectly, so I keep using this one. Thank you for your patience and your work for the registration. Really a great tool that I love to use 👍

@zeratax
Copy link
Owner Author

zeratax commented Jul 11, 2021

since i can't reproduce this at all and you seem to have found a solution I'll consider this fixed until someone says otherwise ^^

@zeratax zeratax closed this as completed Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants