Hi, I have the following Dockerfile:
and I'm trying to deploy on heroku
but I get the error that clojure.main not found.
even when running locally using: docker build -t test . and docker run -ti test I get the same error
I changed the last command to: RUN java $JVM_OPTS -cp target/myapp.jar clojure.main -m myapp.application --server.port=$PORT --server.host=0.0.0.0 It outputs "running on localhost:5000" in Heroku and the app crashes
Now when building, I get the error
Step 7/9 : COPY . .
Error processing tar file(exit status 1): write /target/vendo.jar: no space left on device
โธ Error: docker build exited with Error: 1
Even after doing
docker system prune --volume
How did you build the jar file?
The jar file wasn't built. Here's the updated Dockerfile. But the lein uberjar command doesn't work. I get project.clj not found.
you need to add the project files i think? a COPY . .
is needed before the lein command
docker builds in an isolated environment, you need to add the files otherwise it has no idea of the files in the directory.
I was able to deploy it but it says "started on localhost:5000" on remote?
so you need to mount this port outside the container to access it
you need a -p 5000:5000
with the run command
also it may not be reachable from the outside as its listening to only localhost
If you are new to docker, i could recommend some docker resources first, should help you get docker specific issues sorted first? ๐
sure thanks!
try following https://docs.docker.com/get-started/
this goes through a nodejs setup with a server and mounting ports and has a nice explanation of why is what
i would recommend try this out and get a feel of docker and the clojure thing should be simple after it ๐
the -p 5000:5000 with RUN java $JVM_OPTS -cp target/vendo.jar clojure.main -m vendo.application -p 5000:5000 didn't change anything.
this needs to happen outside with the docker run -p 5000:5000 ...
this happens in 2 steps: - build the image - run with port and volume mounts
again, i really recommend to try the tutorial first, getting the docker concepts first would really help
mixing the clojure and docker issues together would make it a bigger mess i'd say
also this seems nice for a clojure app on docker: https://roboloco.net/blog/clojure-apps-in-docker/
some basic networking know how may be needed to access it properly, I can help out if you face issues then ๐
I'm simply deploying the app using git push heroku master
And the docker stuff seems to happen automatically
How to add the -p 5000:5000... option then?
Here's what I'm looking at: https://devcenter.heroku.com/articles/container-registry-and-runtime
so 2 things i guess:
- you need to EXPOSE the port from docker. you would need a EXPOSE 5000
as one of the lines on the Dockerfile
- the app needs to listen to 0.0.0.0:5000
and its only listening to localhost now i think
the second part depends on the app config, not sure where to change that, its app specific
im not really familiar with heroku, but this seems to be relevant: https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime
It says
โข EXPOSE
ย - Whileย `EXPOSE`ย can be used for local testing, it is not supported in Herokuโs container runtime. Instead your web process/code should get the $PORT environment variable.
yes, your app should read this and listen to this port
this seems to be how heroku works
also your app needs to listen to 0.0.0.0 or all interfaces, its listening on 127.0.0.1 i think. https://serverfault.com/questions/78048/whats-the-difference-between-ip-address-0-0-0-0-and-127-0-0-1
this is the networking thing i was telling about
just making your app listen on 0.0.0.0 should make this work i think :thinking_face:
I found this: https://help.heroku.com/PPBPA231/how-do-i-use-the-port-environment-variable-in-container-based-apps
But I don't know what gunicorn means
this is a python server, not relevant here i think
is your code online somewhere? maybe i can have a look?
how about doing a direct deployment? https://devcenter.heroku.com/articles/getting-started-with-clojure
i feel docker here is adding more complexity
it's because I need python in my app
can i see the myapp.application
namespace?
need to know how you listen
these are all the relevant files I think
okay looks like its listening on 5000 with aleph, does it deploy successfully? and youre able to ping it?
Yes it deploys successfully
are you able to reach it from the heroku url?
it should be i think if the port is correct
no, it says application error
does it have any more logs? like is it from heroku or the app?
also if possible you could paste your app public URL here too?
will have a look tomorrow if still not solved! getting late here, ta! good luck ๐