Description
Because nix is used to build the container image, it's not easy to run alembic.
For 0.9.1
, the alembic
binary happens to be at /nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/bin/alembic
. Seems like we need to set this as an --entrypoint
to invoke it.
It appears that we also need to pass a config to it, which happens to live at /nix/store/5q2rmk3i4cvjzb5x6s19s5gmv34gjpf6-python3.8-matrix-registration/alembic.ini
.
Looks like we also need to run the alembic
command with a working directory like /nix/store/5q2rmk3i4cvjzb5x6s19s5gmv34gjpf6-python3.8-matrix-registration
(passed to docker run
via -w
).
In the end, I've gotten to a command like this:
docker run \
-it \
--rm \
--name matrix-registration-db \
--log-driver=none \
--user=991:991 \
--cap-drop=ALL \
--network=matrix \
--mount type=bind,src=/matrix/matrix-registration/config,dst=/config,ro \
--mount type=bind,src=/matrix/matrix-registration/data,dst=/data \
-w /nix/store/5q2rmk3i4cvjzb5x6s19s5gmv34gjpf6-python3.8-matrix-registration \
--entrypoint=/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/bin/alembic \
docker.io/zeratax/matrix-registration:v0.9.1 \
-c /nix/store/5q2rmk3i4cvjzb5x6s19s5gmv34gjpf6-python3.8-matrix-registration/alembic.ini upgrade head
Yet I still get some error like this:
Traceback (most recent call last):
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/bin/.alembic-wrapped", line 9, in <module>
sys.exit(main())
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/config.py", line 577, in main
CommandLine(prog=prog).main(argv=argv)
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/config.py", line 571, in main
self.run_cmd(cfg, options)
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/config.py", line 548, in run_cmd
fn(
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/command.py", line 298, in upgrade
script.run_env()
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/script/base.py", line 489, in run_env
util.load_python_file(self.dir, "env.py")
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
module = load_module_py(module_id, path)
File "/nix/store/lcbqvdllxb7lnrk85zq4pdl63yxdbb4z-python3.8-alembic-1.4.2/lib/python3.8/site-packages/alembic/util/compat.py", line 184, in load_module_py
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "alembic/env.py", line 14, in <module>
from matrix_registration import config as mr_config
ModuleNotFoundError: No module named 'matrix_registration
So I'm guessing the command above needs even more work.
Is it possible to adjust the container-building script, so that it puts binaries (or symlinks to them) at a predictable path?
What would be the proper way to invoke alembic
from a container image?
Related to spantaleev/matrix-docker-ansible-deploy#1208