How to include a local language server in a dockerfile and build a docker image from it?

[亡魂溺海] 提交于 2019-12-08 04:30:31

问题


I need to run a local language server as a docker container by including it in a dockerfile. I built a simple language server following only the section under "Provide the Xtext Language Server". This is the Dockerfile I wrote to build the image:

FROM eclipse/che
ADD xtextls3 C:\Users\abc\xtext_ls3
RUN sudo apt-get install socat -y
CMD socat TCP4-LISTEN:4417,reuseaddr,form EXEC:"xtextls"

I don't know whether this is correct. "xtextls3" is the eclipse workspace folder I used to create my language server. When I try to build this dockerfile, I get this error: ADD failed: stat /var/lib/docker/tmp/docker-builder342449789/xtextls3

What is the correct method to include my language server in a dockerfile, and build a docker image from it?


回答1:


I might think that the problem lies in the ADD line. This adds the local file xtextls3 to your layer. However, the file cannot be found. I have the idea that you have to swap the first and second argument on the ADD-instruction.




回答2:


It seems that I should be stating the path in relation to the context directory (current location I'm at in the command prompt). I placed my .jar file in the same folder where the Dockerfile is and changed the Dockerfile content as follows:

FROM barais/eclipse-xtend
ADD build/libs/dsl-language-server-ls.jar dsl-language-server-ls.jar
RUN sudo apt-get install socat
CMD socat TCP4-LISTEN:4417,reuseaddr,fork EXEC:"mydsl"

"build/libs/dsl-language-server-ls.jar" is the path+file, and "dsl-language-server-ls.jar" is the binary file that I require.



来源:https://stackoverflow.com/questions/52605341/how-to-include-a-local-language-server-in-a-dockerfile-and-build-a-docker-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!