Running distribution inside docker container?
I built distribution and currently trying to run inside a Docker container but getting such error. Anyone knows what might be the problem?
35 Replies
If I run disribution script, everything is working fine
just sounds like your package or class name is incorrect
you could open the JAR in an archive manager (or rename it to .zip) and check
but I'm imagining it has something to do with your distributions.forEach which sets all distributions to the same JAR name
I haven't actually seen that builder before, though, so just a hunch
Isn't classpath ok?
why are you setting that if you have a
-all
jar?Ah, copied it from jar task, seems like .jar in not needed here
let me delete it
Deleted but the issue still remains
did you check what was actually in the jar?
there were two folders,
bin
and lib
, I was running sh script inside bin folderWhat? That makes no sense
How did those end up in your jar?
It was not jar, I was not using fatJar, I ran
./gradlew installDist
to create distributions
Just I copy pasted the name from fatJar task, thats why it was named that way, my badIsn't there another folder in build/install?
no
there should be
at least according to the docs for the distribution plugin
You can rungradle installDist
to assemble the uncompressed distribution intolayout.buildDirectory.dir("install/${project.name}")
Let me clean all and rerun it
Here is the directory tree
right
And gradle build file
and your dockerfile has
COPY ./build/install/*-all.jar /app/glados.jar
that's not going to copy everythingI changed it to this
Tried even without copying
..ok, well now you have nothing in the container
the command you want is
ADD
ADD ./build/install/glados /app/glados
then everything else has to happen from the context of /app/glados
so probably WORKDIR /app/glados
and work from there
note that only the contents of build/install/glados
will be added, there'll be no extra glados
folder inside /app/glados
So, we end up something like this?
what do you mean by
/bin/glados.sh
you're not putting any files in /bin
I'm getting the feeling that you don't know how unix filesystem paths workWait, when we run
ADD ./build/install/glados /app/glados
don't we just add files from glados directory from install to /app/glados
?yes, exactly
not /bin
Ok, and now my sh file is in
/app/glados
directly or what?according to your code block, it's in
/app/glados/bin
or ./bin
since we set the workdirok
So is everthing right now?
that looks correct
cool, let me prune all and try to run it
Nah, same error
Maybe something is wrong with compose file?
you don't need the
image
property
otherwise I don't think so
technically you don't need platform
eitherWell, I will later on publish it so I can pull it from my linux server to run it
I'm currently on my local macOS machine
oh, I didn't realise you could use compose for publishing
anyway sounds like maybe you should try to inspect the image or contents of the container
ok
I haven't used gradle distributions so I'm not really sure
Will try to found out, if nothing works, guess will need to try with fatJar, anyway, thanks
might have something to do with the cwd on execution
that's the only other hint I could think of
I tested the distribution plugin locally and it worked, but I didn't put it into a container
Yeah, similarly when I run it locally it works, but when try to run in container its failing