COMMUNITY

Haxe docker

docker

(Postite) #1

hello all,
i’m interested in using a docker container for testing different versions of haxe . so i tried the haxe docker library . As a first time docker user, i managed to run my image, compile some hxml and get the whole stuff.
But i didn’t succeed in running nekotools server and access it on the host via a browser.
does anyone has experience on this?
here is the dockerfile i use.

FROM haxe:3.4

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# install dependencies
COPY *.hxml /usr/src/app/
RUN yes | haxelib install all

# compile the project
COPY . /usr/src/app
RUN haxe build.hxml


EXPOSE 2000

# run the output when the container starts
#CMD ["neko", "Main.n"]
CMD ["nekotools", "server"]

then

$ docker build -t dosh
$ docker run --name bim  -d -p 40013:2000 dosh
$ curl --verbose http://192.168.99.100:40013/index.n
*   Trying 192.168.99.100...
* connect to 192.168.99.100 port 40013 failed: Connection refused
* Failed to connect to 192.168.99.100 port 40013: Connection refused
* Closing connection 0

any help ?
thx


(Valentin Lemière) #2

It might be

I think that runs nekotools "nekotools server" and that you want CMD ["nekotools", "server"] instead.


(Postite) #3

sorry, typo in the post . fixed it …
but that’s not the issue
thx


(Anthony Hawes) #4

When you run docker ps what interfaces/ports are shown?


(Postite) #5

hi ! i got this :


(Anthony Hawes) #6

That output looks fine. It’s just dawned on me that nekotools server by default only listens on localhost (i.e. local to the container). You will need to add the parameter -h 0.0.0.0


(Postite) #7

do you mean
$docker run --name bim -d -p 40013:2000 -h 0.0.0.0 dosh
?

doesnt work neither… :frowning:


(Valentin Lemière) #8

The parameter is for nektools: nekotools server -h 0.0.0.0


(Anthony Hawes) #9

Sorry, my fault for being ambiguous. It’s nekotools server -h 0.0.0.0


(Postite) #10

thx @ibilon && @anthonyhawes
EXPOSE 2000
CMD [“nekotools”, “server” ,"-h", “0.0.0.0”] //in dockerfile
run with
docker run -d --name bim -p 2000:2000 dosh

works at
http://192.168.99.100:2000/index.n

pfioou…
thx again


(Postite) #11

now i can begin playing


(Postite) #12

another question …

how would you manage to have a container running with haxe and a server.
and then compile hxml without relaunching the container ?


(Anthony Hawes) #13

Hi,

Can you spell out in more detail what you are trying to achieve?


#14

recompile and restart server w/o restarting container … or more specific module replacing after file save … HMR … I think