:main-opts not used for docker?
Closed this issue ยท 4 comments
First of all, thank you so much for working on great high quality tools and sharing them with the rest of us ๐๐ป .
I think my ignorance is showing with regard to the world of clojure cli tools.
Prior to the rewrite I would build a docker image like so:
$ clojure -A:pack mach.pack.alpha.jib \
--image-name my-image-name \
--image-type registry \
--additional-tag latest \
--extra-java-args -Xmx6g \
-e path/to/classes \
-m my.cool.app
Where path/to/classes was created via aot compiling my app
I am having trouble understanding the new way to do this using as a tool:
$ clojure -T:pack docker \
:basis '{:extra-paths ["classes"] :jvm-opts ["-Xmx2g"] :main-opts ["-m" "my.cool.app"]}' \
:tags '#{"latest"}' \
:to-registry "{:username \"user\" :password \"secret\"}" \
:image-name '"my-image-name"' \
:image-type :registry
I am able to get my image to my desired registry, but when it runs it just opens a repl and then closes - leading me to believe I have something configured incorrectly (particularly with regard to the main opts).
Can someone point me towards my error? I appreciate any help ๐๐ป
So after reading the tools docs, I found you can specify aliases for tools as part of -T
.
If I create a container with -T
and an alias that has some :main-opts
the :main-opts
appear to be ignored.
{:aliases
{:main {:extra-paths ["classes"] ;; aot compiled classes
:main-opts ["-m" "my.cool.app"}}}
Then
$ clojure -T:pack:main docker...
Just running the container does not seem to work (using docker run myimage
). However, if I run the container and provide main opts manually, everything is ok:
$ docker run myimage -m my.cool.app
Am I using :main-opts
incorrectly? Have I found a bug?
The api docs for clojure.tools.deps.alpha make it seem like main-opts isn't present on classpath-args?
You're right, this isn't officially supported but does happen to work. In the future, there will be an official tdeps API for this.
I believe you need to include :aliases
in the basis, see params here: https://github.com/clojure/tools.deps.alpha/blob/f96c0baae1a07ab1c0f914d7baea8c8de2e427eb/src/main/clojure/clojure/tools/deps/alpha.clj#L785
So it would be :aliases [:main]
for you.
Forgot to respond to this. Thank you so much for the response and the work you do on this ๐๐ป