Import login.json automatically in docker compose - #89
Conversation
billyjbryant
left a comment
There was a problem hiding this comment.
There isn't an official version of AnkerMake for Linux at the moment, the only way to circumvent this is with Wine. I think we should replace ankerseed_linux with ankerseed_win and let Linux users fend for themselves with the browser-based upload.
| - ankerctl_vol:/root/.config/ankerctl | ||
| - "$HOME/Library/Application Support/AnkerMake/AnkerMake_64bit_fp/login.json:/tmp/login.json" | ||
| command: sh -c "cp /tmp/login.json /root/.config/ankerctl/login.json || true" | ||
| ankerctl_seed_linux: |
There was a problem hiding this comment.
There is no version of AnkerMake for Linux just yet, and if there is in the future the path will look more like $HOME/.local/share/<AnkerMakeSpecificPath>
There was a problem hiding this comment.
INFORMATIONAL: Not for v1.0.0 ship but for v.1.1 we can look at their alpha build of the new slicer since that does have a linux build.
There was a problem hiding this comment.
Ok after futzing with this for about an hour I have it working this way:
volumes: - ankerctl_vol:/root/.config/ankerctl - $HOME/Library/Application Support/AnkerMake/AnkerMake_64bit_fp/login.json:/tmp/login.json #command: sh -c "cp /tmp/login.json /root/.config/ankerctl/login.json || true"
NO command argument
There was a problem hiding this comment.
🤔 Hmm, that is interesting. If the command argument is commented out then the cp won't work.
I suspect what happened is another previous attempt copied the login.json to the volume.
If you purge your docker volumes, and then try again I'm fairly confident that this will not work with that line commented out.
docker system prune
docker volume rm ankermake-m5-protocol_ankerctl_vol
docker compose up
| - ankerctl_vol:/root/.config/ankerctl | ||
| entrypoint: "/app/ankerctl.py" | ||
| command: ["config", "import", "/root/.config/ankerctl/login.json"] | ||
| depends_on: |
There was a problem hiding this comment.
No ankerseed for Windows? Bind volumes work in Windows too.
There was a problem hiding this comment.
Isn't this just a naming thing though? It's called ankerctl_import and is still importing the login.json file right?
There was a problem hiding this comment.
Good point, lets scrap linux support, and add windows support. Do you know the path on windows?
There was a problem hiding this comment.
The way I understand it, the ankerctl_seed_* containers try to copy-in a login.json file from the host system, and ankerctl_import runs the import action.
@spuder could we make ankerctl_import responsible for all the cp ... || true attempts, and also ankerctl.py config import? That would make this a simple two-step thing.
There was a problem hiding this comment.
Good point, lets scrap linux support, and add windows support. Do you know the path on windows?
%LOCALAPPDATA%\Ankermake\AnkerMake_64bit_fp\login.json
There was a problem hiding this comment.
Or c:\Users\$USER\AppData\Local\Ankermake\AnkerMake_64bit_fp\login.json
There was a problem hiding this comment.
I've tried a few local edits and can't find a way of getting thsi to work for Windows using Docker Desktop on WSL.
|
Should this target |
Its close, but I would say don't delay the release for it. |
| volumes: | ||
| - ankerctl_vol:/root/.config/ankerctl | ||
| # TODO: verify this is the correct linux path | ||
| - "$HOME/AnkerMake/AnkerMake_64bit_fp/login.json:/tmp/login.json" |
There was a problem hiding this comment.
This would be our best bet, for Linux users running ankermake through wine with default settings:
$HOME/.wine/drive_c/users/$USER/AppData/Local/AnkerMake/AnkerMake_64bit_fp/login.json|
|
||
| ankerctl: | ||
| # image: ghcr.io/ankermgmt/ankermake-m5-protocol:latest | ||
| image: ankerctl/ankerctl:latest |
There was a problem hiding this comment.
Can you explain how ankerctl/ankerctl:latest works? I'm not quite familiar with that syntax.
Suppose we make sure ghcr.io/ankermgmt/ankermake-m5-protocol:latest always has a fresh image available. What are the pros/cons of using that image here, vs pointing to ankerctl/ankerctl, which (I imagine) points to the locally-built image?
There was a problem hiding this comment.
Eventually ghcr.io/ankermgmt/ankermake-m5-protocol:latest will be preferred, however for testing it won't work since I need the latest docker container available on my machine.
We can switch ankerctl/ankerctl to ghcr once we have the updated web gui published.
I can actually change this in git, and just override it temporarily while testing.
| volumes: | ||
| - ankerctl_vol:/root/.config/ankerctl | ||
| entrypoint: "/app/ankerctl.py" | ||
| command: ["config", "import", "/root/.config/ankerctl/login.json"] |
There was a problem hiding this comment.
Wouldn't it be simpler to put login.json in (say) /root/login.json?
In fact, this location clashes with an upcoming feature, where it will be possible to select other "profiles" than default.json. (profiles are "complete config imports" - thank of them like browser profiles).
Also, can't we stack ankerctl_seed_mac and ankerctl_seed_linux, by just trying several cp ... || true with different paths? We could try all well-known paths, and if one of them works, we can import it. How does that sound?
I realize now that /root isn't part of the volume, but since we import the config, I suppose that's actually a feature, since the copy of login.json will then be ephemeral, while the imported default.json will be kept. Seems good?
| - ankerctl_vol:/root/.config/ankerctl | ||
| entrypoint: "/app/ankerctl.py" | ||
| command: ["config", "import", "/root/.config/ankerctl/login.json"] | ||
| depends_on: |
There was a problem hiding this comment.
The way I understand it, the ankerctl_seed_* containers try to copy-in a login.json file from the host system, and ankerctl_import runs the import action.
@spuder could we make ankerctl_import responsible for all the cp ... || true attempts, and also ankerctl.py config import? That would make this a simple two-step thing.
| restart: "no" | ||
| volumes: | ||
| - ankerctl_vol:/root/.config/ankerctl | ||
| - "$HOME/Library/Application Support/AnkerMake/AnkerMake_64bit_fp/login.json:/tmp/login.json" |
There was a problem hiding this comment.
This will fail on mac because of the space, you need to properly escape the space between Application and Support.
| - ankerctl_vol:/root/.config/ankerctl | ||
| entrypoint: "/app/ankerctl.py" | ||
| command: ["config", "import", "/root/.config/ankerctl/login.json"] | ||
| depends_on: |
There was a problem hiding this comment.
I've tried a few local edits and can't find a way of getting thsi to work for Windows using Docker Desktop on WSL.
|
After trying numerous techniques, it's clear that this is not quite going to be ready for v1. I've put this on the v1.1 milestone, to give us some time to figure out if this is going to work well. In the meantime, I'm going to implement a small helper script. |


Solves the problem that was discussed in the Discord which I think will make everyone happy 😄
Problem 1: Improve user experience so they only need to run 1
docker composecommand (instead of 2)Problem 2: Attempt to automatically discover login.json on mac/linux machines, and if found, import it. (Eliminating the need to manually import the config file in the gui. Users do not need to memorize
cmd+shift+gor permanently alter their ~/Library visibility settings)How it works
(
ankerctl_seed_mac,ankerctl_seed_linux,ankerctl_import)ankerctl config importto copy the config to the docker volume|| trueto ignore any failures. Containers run withrestart: "no"to happily continue if the import fails (falling back to the default behavior of manually importing config)Known issues / Compromises
This doesn't solve the issue where the config file has to be re-imported every time the container starts, however by automating the import as part of the startup, that is effectively a non-issue.
Summary
This makes
docker compose upjust work on mac and linux with no additional commands