https://github.com/webmatze/crystal_docker_helloworld_sample
How to build a docker application image using a crystal binary
https://github.com/webmatze/crystal_docker_helloworld_sample
Last synced: 8 months ago
JSON representation
How to build a docker application image using a crystal binary
- Host: GitHub
- URL: https://github.com/webmatze/crystal_docker_helloworld_sample
- Owner: webmatze
- Created: 2021-01-08T23:09:25.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-08T23:13:29.000Z (over 5 years ago)
- Last Synced: 2025-02-26T17:47:20.213Z (over 1 year ago)
- Language: Shell
- Size: 0 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hello World Crystal in Docker Example
## Install dependencies
```bash
brew install crystal
```
## Run
```bash
crystal helloworld.cr
```
## Build
We need to build the statically linked binary using alpine linux. So we are using docker:
```bash
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
```bash
./build
```
## build Docker image
```bash
docker build -t helloworld .
```
## run Docker container
```bash
docker run --name helloworld helloworld
```
## References
- https://github.com/crystal-lang/crystal/wiki/Static-Linking
- https://crystal-lang.org/2020/02/02/alpine-based-docker-images.html