/crystal_docker_helloworld_sample

How to build a docker application image using a crystal binary

Primary LanguageShell

Hello World Crystal in Docker Example

Install dependencies

brew install crystal

Run

crystal helloworld.cr

Build

We need to build the statically linked binary using alpine linux. So we are using docker:

docker run --rm -it -v $PWD:/workspace -w /workspace crystallang/crystal:0.32.1-alpine crystal build helloworld.cr --static

or just use the includes build script

./build

build Docker image

docker build -t helloworld .

run Docker container

docker run --name helloworld helloworld

References