billchurch / webssh2

Web SSH Client using ssh2, socket.io, xterm.js, and express. webssh webssh2
MIT License
2.32k stars 530 forks source link

[Notes]: unable to run via docker per instructions #317

Closed kobuki closed 1 year ago

kobuki commented 1 year ago

What happened?

Running the app via docker using the following command fails:

$ docker run --name webssh2 -d -p 2222:2222 -v $PWD/config.json:/usr/src/config.json billchurch/webssh2
f41f6df65f26172b044e3474632af6ca1474238565a14e9f7ef8af9bd8f45f29

Container exits here instantly. Config file attached. Made from sample config file in Git. Output of docker logs below.

config.json.txt

Node Version

N/A

NPM Version

N/A

Server OS Version

Debian 10.12

WebSSH2 release version

N/A

OS and Version of SSH server

N/A

Browser Version

N/A

Relevant log output

$ docker logs webssh2
WebSSH2 service reading config from: /usr/src/config.json
/usr/src/server/app.js:22
  origins: config.http.origins,
                       ^

TypeError: Cannot read property 'origins' of undefined
    at Object.<anonymous> (/usr/src/server/app.js:22:24)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/usr/src/index.js:11:20)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
tip2tail commented 1 year ago

@kobuki @billchurch did you find a fix for this? I had webssh2 working, tweaked the config file and now cannot get it to run at all - even when I revert back to the initial file. Same error

tip2tail commented 1 year ago

I have done some digging and I have found that the built version of server/app.js within the docker image itself differs from the defined source version in a couple of places. See higlighted below: image

I worked around this by duplicating my config to match - e.g. socketio.origins config as http.origins image

As well as session.secret and session.name as express.secret and express.name respectively.

This allows the process to start, however attempting to then launch within the browser results in another error: image

@billchurch is there something going wrong in the compile of the JS?

tip2tail commented 1 year ago

Just to follow up - I have attempted to build a completely fresh version of this with docker and still get the same cursorBlink error

billchurch commented 1 year ago

@tip2tail, sorry I've been out for a bit. looking at this and will fix it this week. thanks for doing the digging.

billchurch commented 1 year ago

@tip2tail

Okay, so I think I see what's happening. In 0.4.7 I'm changing that schema a bit, so the example that's in main now is dev/0.4.7.

If you change the tag of this repository to 0.4.6, the example is correct for that version and should work properly.

https://github.com/billchurch/webssh2/blob/0.4.6/app/config.json.sample

webssh2 % git status
HEAD detached at 0.4.6
nothing to commit, working tree clean
webssh2 % docker run -it --rm -p 2222:2222 -v $PWD/app/config.json.sample:/usr/src/config.json billchurch/webssh2
WebSSH2 service reading config from: /usr/src/config.json
WebSSH2 service listening on 0.0.0.0:2222
kobuki commented 1 year ago

So... as soon as you release 0.4.7, we can run the container without quirks and until then we must manually checkout 0.4.6?

billchurch commented 1 year ago

@kobuki probably a better way you could phrase that to the only developer working on a project for free...

The example config.json you're pulling from main is the development branch. the 0.4.6 tag would contain the correct example config.json (as well as the correct README).

billchurch commented 1 year ago

@kobuki you can feel free to pull billchurch/webssh2:main if you want the current development branch, but its probably not what you want.

kobuki commented 1 year ago

No, I'm thankful for every piece of free software, including yours, that I have access to. I'm saying this as someone who also works on OSS projects even here. But as one I usually try to produce a master that can be used as-is and work on feature branches otherwise. I was a little baffled on why a code that's being regularly maintained refuses to even load its config. But, no offense was intended, I shoulda chosen my wording a bit better, maybe.

In any case, I can try out webssh2 in 0.4.6 now, thanks for the hints!

billchurch commented 1 year ago

if you're using docker, you don't need to checkout anything. A proper config for the version is the only thing you need, which is going to be stored under the tag for that version.

billchurch commented 1 year ago

I updated docker page as well...

tip2tail commented 1 year ago

@billchurch Very much appreciated and thanks for the detail on what the root cause was. Glad to have helped!

Thanks again M