Fork me on GitHub
#pedestal
<
2020-01-28
>
macrobartfast04:01:52

I can't reach the server port (8080 in my case... the default Pedestal port) in a docker container in which pedestal is running on osx, even after adding ::http/host "0.0.0.0" per https://github.com/pedestal/pedestal/issues/604... I've been working on this for several hours... I tested that an apache container running on 8080 is reachable... help.

chrisulloa06:01:59

are you exposing the port properly when running the docker container?

chrisulloa06:01:45

nvm i see you’re in another channel figuring it out

KJO17:01:35

@macrobartfast Not sure if this'll be helpful, but I use the following service map to start pedestal

KJO17:01:44

{::http/host "0.0.0.0"
 ::http/allowed-origins
             {:allowed-origins (fn[_] true)
              :creds true}
 ::http/routes #(deref #'routes)
 ::http/type   :jetty
 ::http/container-options
 {:context-configurator jetty-websocket-configurator
  :h2c? true
  :h2 true
  :ssl? true
  :ssl-port 8081
  :keystore keystore-location
  :key-password "xxxxxxxxxx"
  :security-provider "Conscrypt"}
 ::http/port   8080}
and then the following docker command to bring up the container
docker run --name test --env-file=docker/env_file.txt -p:8081:8081 -it allocations:latest
and that works for me. I'm sure that -p8080:8080 will also work for the non https connection

macrobartfast18:01:29

@christian.gonzalez I was exposing the port in the Dockerfile... I event tried running the container with -P (the capitalized version of the port flag) which tells Docker to pick a random high port, and it was still unreachable.

macrobartfast18:01:55

I switched to Tomcat from Jetty and that worked.

macrobartfast18:01:00

but we never resolved the issue.

chrisulloa18:01:14

weird, we use jetty and pedestal with set up similar to above ^

macrobartfast18:01:24

I know... bizarre.

macrobartfast18:01:36

I like the Jetty version, so would like it to work.

macrobartfast18:01:46

I have no reason I prefer Jetty, though.

chrisulloa18:01:58

are you overriding the pedestal jetty version?

chrisulloa18:01:34

sometimes dependencies will pull in different versions of jetty too

macrobartfast18:01:42

I am.... I included Tomcat in project.clj and the changed the value in the map from Jetty.

macrobartfast18:01:59

Yeah, I was wondering if I should change my versions.

macrobartfast19:01:12

Also, maybe the leiningen Pedestal template?

macrobartfast19:01:37

I couldn't find it in ~/.lein/profiles so not sure where the template is specified.

macrobartfast19:01:08

I must have a more global place I'm setting up lein with the plugin.

chrisulloa19:01:17

lein should pull in the template remotely

chrisulloa19:01:30

lein new pedestal-service my-project

macrobartfast19:01:36

that's what I use.

macrobartfast19:01:41

it's freaking awesome.

macrobartfast19:01:55

I love Pedestal.

chrisulloa19:01:16

what dependencies do you have in your project?

macrobartfast19:01:42

(defproject general-pedestal-service "0.0.1-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.10.1"] [io.pedestal/pedestal.service "0.5.7"] ;; Remove this line and uncomment one of the next lines to ;; use Immutant or Tomcat instead of Jetty: ;; [io.pedestal/pedestal.jetty "0.5.7"] ;; [io.pedestal/pedestal.immutant "0.5.7"] [io.pedestal/pedestal.tomcat "0.5.7"] [ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]] [org.slf4j/jul-to-slf4j "1.7.26"] [org.slf4j/jcl-over-slf4j "1.7.26"] [org.slf4j/log4j-over-slf4j "1.7.26"]] :min-lein-version "2.0.0" :resource-paths ["config", "resources"] ;; If you use HTTP/2 or ALPN, use the java-agent to pull in the correct alpn-boot dependency ;:java-agents [[org.mortbay.jetty.alpn/jetty-alpn-agent "2.0.5"]] :profiles {:dev {:aliases {"run-dev" ["trampoline" "run" "-m" "general-pedestal-service.server/run-dev"]} :dependencies [[io.pedestal/pedestal.service-tools "0.5.7"]]} :uberjar {:aot [general-pedestal-service.server]}} :main ^{:skip-aot true} general-pedestal-service.server)

macrobartfast19:01:26

it's just a bare bones pedestal service to get going with pedestal in docker on kubernetes.

chrisulloa19:01:27

presumably had jetty line uncommented when you were trying that

macrobartfast19:01:42

I did have them uncommented, good thought though.

chrisulloa19:01:54

what java version?

chrisulloa19:01:59

in your dockerfile?

macrobartfast19:01:08

java version "1.8.0_92"

macrobartfast19:01:21

FROM java:8-alpine

macrobartfast19:01:29

the latter is the docker version

chrisulloa19:01:31

not sure what the issue is really

macrobartfast19:01:35

I know, right?

macrobartfast19:01:55

maybe this is the right moment to go with Tomcat and move along.

chrisulloa19:01:06

are you running the service locally with docker or in your kube cluster?

macrobartfast19:01:21

running the service locally.

macrobartfast19:01:02

well, first was going to run the service in a container, then run the container in the cloud in a small vps, then figure out some kube workflow.

macrobartfast19:01:09

a big step for me, all that.

macrobartfast19:01:44

terrifying devops rabbithole.

macrobartfast19:01:13

with this issue, I feel like a olympic sprinter who's tripped at the start.

macrobartfast19:01:57

maybe it's a test... do I just go with Tomcat and move on, or spend a day resolving the Jetty issue when it has no material effect?

chrisulloa19:01:55

might be good to just run with tomcat and come back to it later

chrisulloa19:01:15

make an issue in pedestal since they are providing template

macrobartfast19:01:36

down the road, you'll be one of the few Jedis who knows why Encom uses Tomcat.

chrisulloa19:01:33

might also be an issue with your local machine

macrobartfast19:01:41

I suspect it is.

chrisulloa19:01:56

might be worth sending docker container and run script to another dev and trying

macrobartfast19:01:08

brilliant idea.

macrobartfast19:01:30

and also, pull down a working pedestal service that's known to work and try it locally.

chrisulloa19:01:54

we have multiple services that use pedestal, same set up more or less just on different ports

macrobartfast19:01:49

oh, one interesting thing, when I deployed to digital ocean...

macrobartfast19:01:53

it didn't work.

macrobartfast19:01:14

so I should try a node app or something and see if it works in the cloud.

macrobartfast19:01:22

sounds like I have my next steps cut out for me.

chrisulloa19:01:39

maybe someone will chime in later who knows more

macrobartfast19:01:29

and yes. the fact that it didn't work in the cloud tells me that something is wrong with my dependencies... I'm shipping the problem up to my vps and it's occurring there.

macrobartfast20:01:45

haha well... got the Tomcat version of the Pedestal service deployed in the cloud and got an SSH error ( java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens ) so maybe I dooo like Jetty more. That may have happened with Jetty, too, for all I know. https://stackoverflow.com/questions/42218237/java-lang-illegalargumentexception-invalid-character-found-in-method-name-http

macrobartfast20:01:33

oh duh. works if you request via http. I shouldn't have shared my little journey.

😂 8