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?
@yefoakira Can you share your Dockerfile and docker-compose.yml here?
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
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "4001:8080"
volumes:
- .:/usr/src/app
command: lein run-dev
I see that your Dockerfile copies the project.clj into the container, but I don't see how your application source gets copied.
volumes:
on docker-compose
links my folder with my source into /usr/src/app
Oh, right.
What do you see in the logs from docker-compose?
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.URL being something like http://localhost:4001/ ?
yep
Well, that was the obvious stuff. Give me a minute to try to replicate the problem.
What OS are you on?
Is your project.clj straight from the leiningen template?
Linux Mint. Other than adding midje, yep.
I've more or less reproduced the problem.
I'm on Windows with WSL rather than Linux, so there's bound to be a little variation.
Instead of connection reset, I get an empty response.
The issue is that Jetty only binds to a server socket on "localhost".
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
With that, I'm able to get a good response from the host.
Oooooohhh. Completely missed that. Thanks 😊
yw