nrepl

jcd 2025-04-04T15:34:34.109449Z

I’m trying to run an nrepl via lein in a docker container and jack into it from my local. I’m having trouble actually exposing the port. The port is opened according to docker compose. Is there some other flag I need to invoke? I have tried setting the :host to both local host and 0.0.0.0 via lein in the container.

oyakushev 2025-04-04T15:38:07.960279Z

How does the compose look like? And what does docker ps show?

jcd 2025-04-04T15:49:23.348529Z

Docker compose:

clojure-app:
    environment:
      - GITHUB_ACTOR
      - GITHUB_TOKEN
      - DATABASE_URL=jdbc:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        GITHUB_ACTOR: $GITHUB_ACTOR
        GITHUB_TOKEN: $GITHUB_TOKEN
    volumes:
      - .:/opt/treasuryprime/core
    working_dir: /opt/treasuryprime/core
    command: 'lein with-profile dev repl :headless :host 0.0.0.0 :port 40000'
    ports:
      - 40000:40000
    depends_on:
      - db
Docker ps:
CONTAINER ID   IMAGE              COMMAND                  CREATED             STATUS             PORTS                                         NAMES
65e888da4ad6   core-clojure-app   "lein with-profile d…"   About an hour ago   Up About an hour                                                 core-clojure-app-run-3cdebf92301e
33af2b0dea6c   postgres:15        "docker-entrypoint.s…"   21 hours ago        Up 21 hours        0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp   core-db-1

jcd 2025-04-04T15:50:20.609689Z

Fixed the formatting.

Ivar Refsdal 2025-04-07T09:01:16.069229Z

That does not show any mapped ports for the clojure app. So the bug is in the compose file I think

oyakushev 2025-04-07T09:11:56.943619Z

Yeah, sorry, I forgot to answer. The created Clojure container is missing ports indeed

Ivar Refsdal 2025-04-07T09:25:03.161249Z

IIRC yaml have some crazy number format support, so I would quote those numbers

Ivar Refsdal 2025-04-07T09:26:44.404729Z

I would try: - "127.0.0.1:40000:40000" as per https://stackoverflow.com/questions/35429837/docker-compose-port-mapping#46220742

Ivar Refsdal 2025-04-07T09:30:54.251919Z

Yeah, there it is: yaml 1.1 supports sexagesimal (base 60) number literals: https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell#sexagesimal-numbers What a feature.

😱 2
jcd 2025-04-07T13:50:19.333249Z

That did the trick for opening the port, thank you! The repl is still hiccuping and dropping connections, but I am able to attempt to connect and will dig into that. Appreciate the help!

jcd 2025-04-07T14:22:01.427279Z

the trick for actually receiving non-local nrepl connections was to specify the port on the lein invocation.