solargraph
solargraph in docker for use with IDEs
114
Docker image for the Ruby language server Solargraph
For use with the Ruby Solargraph (castwide.solargraph) VSCode Extension, add
the following to VSCode's settings:
~/.config/Code/User/settings.json:
{
"solargraph.externalServer": {
"host": "localhost",
"port": 7658
}
}
Run the server on port 7658:
docker run --name=solargraph-ruby --rm -d -p 7658:7658/tcp \
-v $HOME/src/pub:$HOME/src/pub:ro \
trinitronx/solargraph:0.56.2-ruby-3.4.5-alpine3.22
Note that the source code paths should match inside and outside the container.
Ensure that the -v volume mount paths match your source code directory.
If you find this project useful and appreciate my work, would you be willing to click one of the buttons below to Sponsor this project and help me continue?
Every little bit is appreciated! Thank you! 🙏
The docker container's entrypoint.sh script supports volume mounting the cache
& config directories as read/write. In order to ensure proper file permissions,
the user & group IDs should match inside and outside the container. To do this,
set the UID and GID environment variables to match those on the docker host.
Note that RubyGem's cache dir should also be mounted ($XDG_CACHE_HOME/gem).
Then, volume mount solargraph's cache and config directories as :rw and
create a default config file if it does not already exist with:
docker run --name=solargraph-ruby -ti --rm -ti \
-v $HOME/src/pub:$HOME/src/pub:ro \
--workdir $PWD \
-e UID=$(id -u) -e GID=$(id -g) \
-v ${XDG_CACHE_HOME:-$HOME/.cache}/solargraph:/home/solargraph/.cache/solargraph:rw \
-v ${XDG_CACHE_HOME:-$HOME/.cache}/gem:/home/solargraph/.cache/gem:rw \
-v ${XDG_CONFIG_HOME:-$HOME/.config}/solargraph:/home/solargraph/.config/solargraph:rw \
trinitronx/solargraph:0.56.2-ruby-3.4.5-alpine3.22 \
config /home/solargraph/.config/solargraph
The container runs a bundle install as root to install your project's Ruby
gems into the container's system GEM_PATH location. It also supports
installing system packages during startup with Alpine Linux's apk package
manager. Together, these features allow many gem native extensions to install,
and build using system-level headers and dependencies.
To use this feature, set the environment variable SOLARGRAPH_APK_PKGS to a
space-separated list of Alpine Linux packages to install.
For example, the nokogiri gem needs libffi-dev to install its native
extensions. So, to install it prior to the bundle install, simply add it to
the SOLARGRAPH_APK_PKGS environment variable passed to the container.
docker run --name=solargraph-ruby --rm -d -p 7658:7658/tcp \
-v $HOME/src/pub:$HOME/src/pub:ro \
--workdir $PWD \
-e SOLARGRAPH_APK_PKGS='libffi-dev' \
-e UID=$(id -u) -e GID=$(id -g) \
-v ${XDG_CACHE_HOME:-$HOME/.cache}/solargraph:/home/solargraph/.cache/solargraph:rw \
-v ${XDG_CACHE_HOME:-$HOME/.cache}/gem:/home/solargraph/.cache/gem:rw \
-v ${XDG_CONFIG_HOME:-$HOME/.config}/solargraph:/home/solargraph/.config/solargraph:rw \
trinitronx/solargraph:0.56.2-ruby-3.4.5-alpine3.22
Content type
Image
Digest
sha256:6878b741c…
Size
156 MB
Last updated
8 months ago
Requires Docker Desktop 4.37.1 or later.