docker compose doesn't pass cli arguments
zeratax opened this issue · comments
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)
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
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
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???
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
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"
client_redirect
dos NOT redirect to given url. Instead after register it redirects to register page again- not sure that
-m
when creating a token does what it should. Registered 3 test users with that token butapi/token
still shows me its used once only
it will use the last provided --config-path. so you should be able to just overwrite it
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
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
@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)
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
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.
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'
@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 👍
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 ^^