crystal-devbox

crystal-devbox is a completely dockerized development environment for the Crystal language on Linux.

The Docker image contains Crystal itself (compiler, playground, etc.), the API documentation, the crystal-book (language reference), the VSCodium editor, some OpenVSX-extensions (vsix) and the language server Crystalline. Further some important development packages and commandline tools (e.g. git, gcc, make) are also available inside (look at Dockerfile).

The basic idea behind was to have a completely bundled development environment also for using offline or behind a firewall. The running Docker container includes enough X11 stuff for launching UI tools (Firefox & VSCodium).

Basically all necessary programs, tools and packages are living inside the image/container. However all projects, configurations and other data are awaited outside below the $HOME directory.

The user inside and outside of the running container is exactly the same user (uid, gid, etc.), only the prompt of the shell is changing (starts with a whale and ends with a gemstone) to recognize where you are.

The Docker container starts with several Linux-specific bind mounts. I don't know if this works also on MacOS or Windows.

Okay, the Docker image is not the smallest (~2GB), but it is as small as possible by build ;-)

Requirements

Build

Build the Docker image for yourself online by running the bash script ./build-image.sh. Inside the script set the wanted CRYSTAL_VERSION before. The build can take several minutes. For offline usage the Docker image can be transfered by docker save/load. Already built images of different Crystal versions can also be found at https://hub.docker.com/repository/docker/4ndyfix/crystal-devbox.

Run

Start the Crystal devbox by running the shell script ./run-crystal-devbox.sh in a terminal. Now you are inside the Crystal devbox (in the running Docker container). The shell prompt has changed. Next you can start tools by commandline (CLI) or via a small Kemal-webservice & Firefox browser (UI).

CLI

Run the devbox-launcher binary launcher -h. Available options are:

-r, --reference                  Open Crystal book (language reference)
-a, --api                        Show Crystal API documentation
-p, --playground                 Launch Crystal playground
-c, --vscodium                   Start VSCodium Editor
-n, --no-colorize                No colorized console output
-l LEVEL, --log-level=LEVEL      Logging level as string
-s, --show-config-only           Show config only (instance vars)
-v, --version                    Show Crystal version info
-h, --help                       Show this help

UI

Run the devbox-launcher shell script launcher-ui.sh. It starts the devbox-launcher binary launcher in UI mode. This means a Kemal-service is running now and a Firefox browser comes up as UI.

Hints & Experience

Contributing

  1. Fork it (https://github.com/4ndyfix/crystal-devbox/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors