Sign inSign up

pgeraghty/alpine-crystal

By pgeraghty

•Updated about 7 years ago

Alpine image with Crystal installed to build statically-linked applications

Image
0

1.5K

pgeraghty/alpine-crystal repository overview

⁠Alpine Crystal image

Build Status Docker Automated build Docker Stars Docker Pulls

Alpine image with Crystal installed alongside sufficient packages to build statically-linked Crystal applications for easy deployment and distribution.

⁠Available Docker tags

Each tag links to the relevant Dockerfile.

TagCrystal versionAlpine version
latest⁠0.31.0-r0v3.10
0.31⁠0.31.0-r0v3.10
0.30⁠0.30.1-r1v3.10
0.29⁠0.29.0-r0v3.10
0.27⁠0.27.0-r0v3.9

⁠Usage

For the purposes of these instructions, your application's source code is assumed to be in ./src with the main entry point (or target) in ./src/app.cr.

Add this hack⁠ to your main application file to allow you to build a statically-linked executable:

echo '# prevents segfault during static linking on Alpine, ignored otherwise
{% if flag?(:static) %}
  require "llvm/lib_llvm"
  require "llvm/enums"
{% end %}' >> src/app.cr

To compile the application for release:

docker run --rm --user $(id -u) --env UID=$(id -u) --env GID=$(id -g) -it -v $PWD:/app -w /app pgeraghty/alpine-crystal:latest crystal build --static --release --no-debug src/app.cr

This will build a statically-linked app binary in the current directory without symbolic debug info. The additional user flags should avoid restrictive permissions being applied to the generated file.

Tag summary

Content type

Image

Digest

Size

165.1 MB

Last updated

about 7 years ago

docker pull pgeraghty/alpine-crystal