nwolverson / purescript-ide-purescript-core

Deprecated, to be deleted
MIT License
11 stars 1 forks source link

Possible to run psc-ide-server, etc. in docker? #10

Open unthingable opened 6 years ago

unthingable commented 6 years ago

Tried the naive thing by "purescript.pscIdeServerExe": "docker-compose run --rm purescript psc-ide-server", which is a valid command in the workspace directory, but of course the core code expects to find the executable on $PATH (the emacs PS integration seems to follow a similar pattern).

Other than wrapping docker calls in executable scripts or submitting a PR, is there a canonical way?

nwolverson commented 6 years ago

Firstly, do you mean to run psc-ide-server rather than the combined purs executable that recent compiler versions use?

The code for launching the IDE server is here: https://github.com/kRITZCREEK/purescript-psc-ide/blob/master/src/PscIde/Server.purs

You could write a wrapper script to start a server in docker, but you'd need to do a dance to ensure that works with the randomly chosen port number - instead I'd suggest starting the server yourself.

So e.g. start a purs ide server -p 54321 in docker exposing some port 54321, and echo -n 54321 > .psc-ide-port before starting. The cwd of the server has to match the project directory, so I'd imagine that may be an issue to running inside docker in general.

How are you consuming this package?

unthingable commented 6 years ago

I picked the first ps-docker image I found (https://github.com/Risto-Stevcev/purescript-docker) and ran with it, seems to be using recent enough PS but I didn't see the purs executable.

Thanks! Starting the server separately should be a viable solution, will try that.

The use case is using VSCode with PS in a class setting and attempting to provide an OS-agnostic turn-key development environment to the participants. Docker mounts the project directory as a volume. If file paths that VSCode and PS executables see have to match this could be a problem, but an addressable one, I think.

This package: not consuming it, was just poking around the plugin code to see how the IDE server is started and found this.

unthingable commented 6 years ago

Looks like it's ultimately easier to install npm natively and do it the regular way.

nwolverson commented 6 years ago

Don't understand the npm reference, purescript doesn't require npm (you can get binary directly) and while the language server is a node module I think it should work the same as other node modules used by vscode extensions.

Or for docker option maybe just run pscid inside container and forego editor integration

On 13 Jan 2018 22:27, "Alex" notifications@github.com wrote:

Looks like it's ultimately easier to install npm natively and do it the regular way.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nwolverson/purescript-ide-purescript-core/issues/10#issuecomment-357472221, or mute the thread https://github.com/notifications/unsubscribe-auth/ACpHy8UqURgaAxmAjcyUMLdFWMvu5m-Lks5tKS3rgaJpZM4RcW0C .

unthingable commented 6 years ago

Apologies for obscurity! I was referring to my use case and the original idea of having students work in VSCode/Atom with a self-contained development environment (with PS, node for running web servers, etc.) instead of installing the npm/node/PS stack natively on their platform. The IDE server was just the first stumbling block I encountered.

TL;DR the attempt to simplify environment setup using VSCode and docker was flawed and this issue can be closed or become a low-priority feature request.

nwolverson commented 6 years ago

No problem, I'll certainly leave the issue open as it's a valid use case, just has several issues to solve. I had a similar experience doing Advent of Code in multiple languages, getting a compiler running inside Docker was straightforward but tooling assumes a native installation

chrissound commented 1 year ago

Using the docker image from https://github.com/codewars/purescript this works perfectly for me:

docker run --name pscript --net=host -v $PWD:/$PWD -it --entrypoint bash  --rm ghcr.io/codewars/purescript -c "cd $PWD; purs ide server -p 1234"

I have to set the extension settings to use port 1234 and also change the build command to docker exec -it pscript bash -c "cd $PWD; spago build --purs-args --json-errors".