docker

Spaceman 2020-04-08T14:33:53.015800Z

Hi, I have the following Dockerfile:

Spaceman 2020-04-08T14:34:09.016600Z

and I'm trying to deploy on heroku

Spaceman 2020-04-08T14:34:19.017Z

but I get the error that clojure.main not found.

Spaceman 2020-04-08T14:35:11.017700Z

even when running locally using: docker build -t test . and docker run -ti test I get the same error

Spaceman 2020-04-08T14:38:15.017900Z

Spaceman 2020-04-09T15:42:30.032100Z

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

Spaceman 2020-04-09T20:44:07.032400Z

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

lispyclouds 2020-04-08T15:56:50.018400Z

How did you build the jar file?

Spaceman 2020-04-08T20:14:16.018800Z

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.

lispyclouds 2020-04-08T20:23:31.019200Z

you need to add the project files i think? a COPY . . is needed before the lein command

lispyclouds 2020-04-08T20:24:54.019400Z

docker builds in an isolated environment, you need to add the files otherwise it has no idea of the files in the directory.

๐Ÿ‘ 1
Spaceman 2020-04-08T20:33:32.019700Z

I was able to deploy it but it says "started on localhost:5000" on remote?

lispyclouds 2020-04-08T20:34:12.019900Z

so you need to mount this port outside the container to access it

lispyclouds 2020-04-08T20:34:37.020100Z

you need a -p 5000:5000 with the run command

lispyclouds 2020-04-08T20:35:17.020300Z

also it may not be reachable from the outside as its listening to only localhost

lispyclouds 2020-04-08T20:36:52.020500Z

If you are new to docker, i could recommend some docker resources first, should help you get docker specific issues sorted first? ๐Ÿ™‚

Spaceman 2020-04-08T20:38:59.020700Z

sure thanks!

lispyclouds 2020-04-08T20:40:13.020900Z

try following https://docs.docker.com/get-started/

lispyclouds 2020-04-08T20:40:51.021200Z

this goes through a nodejs setup with a server and mounting ports and has a nice explanation of why is what

lispyclouds 2020-04-08T20:41:27.021400Z

i would recommend try this out and get a feel of docker and the clojure thing should be simple after it ๐Ÿ™‚

Spaceman 2020-04-08T20:43:31.021600Z

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.

lispyclouds 2020-04-08T20:44:09.021800Z

this needs to happen outside with the docker run -p 5000:5000 ...

lispyclouds 2020-04-08T20:44:31.022Z

this happens in 2 steps: - build the image - run with port and volume mounts

lispyclouds 2020-04-08T20:45:11.022200Z

again, i really recommend to try the tutorial first, getting the docker concepts first would really help

lispyclouds 2020-04-08T20:46:05.022400Z

mixing the clojure and docker issues together would make it a bigger mess i'd say

lispyclouds 2020-04-08T20:50:57.022600Z

also this seems nice for a clojure app on docker: https://roboloco.net/blog/clojure-apps-in-docker/

lispyclouds 2020-04-08T20:51:49.022900Z

some basic networking know how may be needed to access it properly, I can help out if you face issues then ๐Ÿ™‚

๐Ÿ‘ 1
Spaceman 2020-04-08T20:52:22.023100Z

I'm simply deploying the app using git push heroku master

Spaceman 2020-04-08T20:52:31.023300Z

And the docker stuff seems to happen automatically

Spaceman 2020-04-08T20:52:45.023500Z

How to add the -p 5000:5000... option then?

Spaceman 2020-04-08T20:54:36.023800Z

Here's what I'm looking at: https://devcenter.heroku.com/articles/container-registry-and-runtime

lispyclouds 2020-04-08T20:58:11.024100Z

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

lispyclouds 2020-04-08T20:58:39.024300Z

the second part depends on the app config, not sure where to change that, its app specific

lispyclouds 2020-04-08T21:01:01.024500Z

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

Spaceman 2020-04-08T21:02:34.024900Z

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.

lispyclouds 2020-04-08T21:02:57.025100Z

yes, your app should read this and listen to this port

lispyclouds 2020-04-08T21:03:08.025300Z

this seems to be how heroku works

lispyclouds 2020-04-08T21:04:15.025500Z

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

lispyclouds 2020-04-08T21:05:06.025900Z

this is the networking thing i was telling about

๐Ÿ‘ 1
lispyclouds 2020-04-08T21:07:14.026200Z

just making your app listen on 0.0.0.0 should make this work i think :thinking_face:

Spaceman 2020-04-08T21:11:33.026600Z

But I don't know what gunicorn means

lispyclouds 2020-04-08T21:12:17.026800Z

this is a python server, not relevant here i think

lispyclouds 2020-04-08T21:12:49.027Z

is your code online somewhere? maybe i can have a look?

lispyclouds 2020-04-08T21:14:23.027200Z

how about doing a direct deployment? https://devcenter.heroku.com/articles/getting-started-with-clojure

lispyclouds 2020-04-08T21:14:42.028Z

i feel docker here is adding more complexity

Spaceman 2020-04-08T21:15:07.028200Z

it's because I need python in my app

lispyclouds 2020-04-08T21:16:01.028500Z

can i see the myapp.application namespace?

Spaceman 2020-04-08T21:16:02.028700Z

lispyclouds 2020-04-08T21:16:14.029100Z

need to know how you listen

Spaceman 2020-04-08T21:16:49.029300Z

Spaceman 2020-04-08T21:17:30.029700Z

these are all the relevant files I think

lispyclouds 2020-04-08T21:19:28.029900Z

okay looks like its listening on 5000 with aleph, does it deploy successfully? and youre able to ping it?

Spaceman 2020-04-08T21:19:56.030100Z

Yes it deploys successfully

lispyclouds 2020-04-08T21:20:36.030300Z

are you able to reach it from the heroku url?

lispyclouds 2020-04-08T21:20:51.030500Z

it should be i think if the port is correct

Spaceman 2020-04-08T21:20:56.030700Z

no, it says application error

lispyclouds 2020-04-08T21:25:37.030900Z

does it have any more logs? like is it from heroku or the app?

lispyclouds 2020-04-08T21:27:50.031200Z

also if possible you could paste your app public URL here too?

lispyclouds 2020-04-08T21:34:55.031700Z

will have a look tomorrow if still not solved! getting late here, ta! good luck ๐Ÿ™‚