pedestal

yefoakira 2018-12-15T22:13:07.033200Z

Hello, just starting with pedestal. I have the hello-world example. When I use from my terminal lein run-dev I get the expected answer. I have added a Dockerfile and a docker-compose.yml running the same command. The jetty server starts inside the container, but I get a connection was reset when navigating to the correct port. I'm using (constantly true) for :allowed-origins. Does anyone know what I am missing?

mtnygard 2018-12-15T22:13:51.033700Z

@yefoakira Can you share your Dockerfile and docker-compose.yml here?

yefoakira 2018-12-15T22:14:30.034200Z

Sure Dockerfile:

FROM clojure:lein
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app
RUN lein deps
EXPOSE 8080

yefoakira 2018-12-15T22:14:55.034600Z

docker-compose.yml

version: '3'
services:
  web:
    build: .
    ports:
      - "4001:8080"
    volumes:
      - .:/usr/src/app
    command: lein run-dev

mtnygard 2018-12-15T22:16:40.035100Z

I see that your Dockerfile copies the project.clj into the container, but I don't see how your application source gets copied.

yefoakira 2018-12-15T22:17:55.036Z

volumes: on docker-compose links my folder with my source into /usr/src/app

mtnygard 2018-12-15T22:18:13.036300Z

Oh, right.

mtnygard 2018-12-15T22:18:29.036700Z

What do you see in the logs from docker-compose?

yefoakira 2018-12-15T22:19:37.037400Z

last lines are:

web_1  | 22:11:32.242 [main] INFO org.eclipse.jetty.server.Server - Started @2471ms
web_1  | 22:11:32.242 [qtp1315795813-24] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run acceptor-1@408a247c
web_1  | 22:11:32.242 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @2471ms org.eclipse.jetty.server.Server@7c0da600[9.4.10.v20180503]
And nothing comes out when I go the url location.

mtnygard 2018-12-15T22:20:04.037700Z

URL being something like http://localhost:4001/ ?

yefoakira 2018-12-15T22:21:23.037900Z

yep

mtnygard 2018-12-15T22:22:32.038300Z

Well, that was the obvious stuff. Give me a minute to try to replicate the problem.

mtnygard 2018-12-15T22:22:40.038600Z

What OS are you on?

mtnygard 2018-12-15T22:24:30.039Z

Is your project.clj straight from the leiningen template?

yefoakira 2018-12-15T22:26:30.039500Z

Linux Mint. Other than adding midje, yep.

mtnygard 2018-12-15T22:33:18.039900Z

I've more or less reproduced the problem.

mtnygard 2018-12-15T22:33:30.040300Z

I'm on Windows with WSL rather than Linux, so there's bound to be a little variation.

mtnygard 2018-12-15T22:33:37.040700Z

Instead of connection reset, I get an empty response.

mtnygard 2018-12-15T22:34:30.041100Z

The issue is that Jetty only binds to a server socket on "localhost".

mtnygard 2018-12-15T22:34:56.041700Z

To get it to listen for connections on any other IP address than 127.0.0.1, you can set the ::http/host key to "0.0.0.0" in service.clj

👍 1
mtnygard 2018-12-15T22:35:12.042100Z

With that, I'm able to get a good response from the host.

yefoakira 2018-12-15T22:42:28.042800Z

Oooooohhh. Completely missed that. Thanks 😊

mtnygard 2018-12-15T22:42:37.043Z

yw