zhaofengli / attic

Multi-tenant Nix Binary Cache
https://docs.attic.rs
Other
1.04k stars 79 forks source link

attic-server Docker image run fails #96

Closed evenbrenden closed 1 year ago

evenbrenden commented 1 year ago

The attic-server:main build fails when I try to run it:

> docker load -i $(nix build --print-out-paths github:zhaofengli/attic#attic-server-image)
0b31fe12b1c0: Loading layer [==================================================>]  101.2MB/101.2MB
Loaded image: attic-server:main

> docker run -t attic-server:main
Attic Server 0.1.0 (release)
Error: No such file or directory (os error 2)

From what I can tell, the image is fine per the GitHub Actions workflow, so am I missing something?

Tested at https://github.com/zhaofengli/attic/commit/e9918bc6be268da6fa97af6ced15193d8a0421c0.

cole-h commented 1 year ago

You likely need to set the the ATTIC_SERVER_BASE64_CONFIG environment variable to the base64-encoded server.toml. It's probably trying to read a $XDG_CONFIG_DIR/attic/server.toml file that doesn't exist.

The docker image doesn't run in monolithic mode by default, which is probably why this is happening. If you create a custom image that doesn't specify --mode (or specifies --mode monolithic), it'll create a config for you:

https://github.com/zhaofengli/attic/blob/e9918bc6be268da6fa97af6ced15193d8a0421c0/server/src/main.rs#L70

(where that second argument determines if the server will setup the "OOBE" (Out-Of-Box Experience) by creating a config and root token for you)

So your course of action should probably be to copy the template.toml, modify it, and then load it base64'd into the environment like so: export ATTIC_SERVER_BASE64_CONFIG="$(cat config.toml | base64 -w0)" (or however you'd do that with docker).

evenbrenden commented 1 year ago

Changing the image to run in monolithic mode does the trick. Thanks!