docker 2020-04-08

@pshar10 has joined the channel

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.

๐Ÿ‘ 1

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!

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 ๐Ÿ™‚

๐Ÿ‘ 1

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?

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

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

๐Ÿ‘ 1

just making your app listen on 0.0.0.0 should make this work i think ๐Ÿค”

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?

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 ๐Ÿ™‚

did it work?

@prikshet21 has joined the channel

@iammiles has left the channel