├── README.markdown └── bin ├── compile ├── detect └── release /README.markdown: -------------------------------------------------------------------------------- 1 | # Crystal Heroku Buildpack 2 | 3 | You can create an app in Heroku with Crystal's buildpack by running the 4 | following command: 5 | 6 | ```bash 7 | $ heroku create myapp --buildpack https://github.com/zamith/heroku-buildpack-crystal.git 8 | ``` 9 | 10 | In order for the buildpack to work properly you should have a `shard.yml` 11 | file, as it is how it will detect that your app is a Crystal app. 12 | 13 | To learn more about using custom buildpacks in Heroku, read [their docs](https://devcenter.heroku.com/articles/third-party-buildpacks#using-a-custom-buildpack). 14 | 15 | ## Older versions of Crystal 16 | 17 | If you have and older version of Crystal (`<= 0.9`), that uses the old 18 | `Projectfile` way of handling dependencies, you can use 19 | [version 1.0](https://github.com/zamith/heroku-buildpack-crystal/tree/v1.0.0) of 20 | the buildpack. 21 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # YAML parser from https://gist.github.com/pkuczynski/8665367 4 | parse_yaml() { 5 | local prefix=$2 6 | local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') 7 | sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ 8 | -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | 9 | awk -F$fs '{ 10 | indent = length($1)/2; 11 | vname[indent] = $2; 12 | for (i in vname) {if (i > indent) {delete vname[i]}} 13 | if (length($3) > 0) { 14 | vn=""; for (i=0; i Installing Crystal" 29 | mkdir -p $CRYSTAL_DIR 30 | curl -sL $CRYSTAL_URL | tar xz -C $CRYSTAL_DIR --strip-component=1 31 | 32 | # Build the project 33 | cd $BUILD_DIR 34 | 35 | if [ -f shard.yml ]; then 36 | echo "-----> Installing Dependencies" 37 | $CRYSTAL_DIR/bin/crystal deps 38 | 39 | if [ -f app.cr ]; then 40 | printf "-----> DEPRECATED: Your main file should have the name of your shard and not app.cr.\nCompiling app.cr" 41 | $CRYSTAL_DIR/bin/crystal build app.cr --release 42 | else 43 | eval $(parse_yaml shard.yml "shard_") 44 | echo "-----> Compiling src/${shard_name}.cr (auto-detected from shard.yml)" 45 | $CRYSTAL_DIR/bin/crystal build src/${shard_name}.cr --release -o app 46 | fi 47 | else 48 | printf "-----> DEPRECATED: You are using an old version of the dependency manager, please look at https://github.com/ysbaddaden/shards for information on the currently advised method.\nCompiling app.cr" 49 | $CRYSTAL_DIR/bin/crystal build app.cr --release 50 | fi 51 | 52 | -------------------------------------------------------------------------------- /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f $1/shard.yml ]; then 4 | echo "Crystal" 5 | exit 0 6 | else 7 | exit 1 8 | fi 9 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cat << EOF 4 | --- 5 | addons: 6 | default_process_types: 7 | web: ./app --port \$PORT 8 | EOF 9 | --------------------------------------------------------------------------------