Coder Social home page Coder Social logo

heroku-buildpack-crystal's Introduction

Crystal Heroku Buildpack

You can create an app in Heroku with Crystal's buildpack by running the following command:

$ heroku create myapp --buildpack https://github.com/crystal-lang/heroku-buildpack-crystal.git

The default behaviour is to use the latest crystal release. If you need to use a specific version create a .crystal-version file in your application root directory with the version that should be used (e.g. 0.17.1).

Requirements

In order for the buildpack to work properly you should have a shard.yml file, as it is how it will detect that your app is a Crystal app.

Your application has to listen on a port defined by Heroku. It is given to you through the command line option --port and the environment variable PORT (accessible through ENV["PORT"] in Crystal). However, most web frameworks should handle this for you.

Testing

To test a change to this buildpack, write a unit test in tests/run that asserts your change and run make test to ensure the change works as intended and does not break backwards compatibility.

More info

To learn more about how to deploy a Crystal application to Heroku, read our blog post.

Older versions of Crystal

If you have and older version of Crystal (<= 0.9), that uses the old Projectfile way of handling dependencies, please upgrade :-).

heroku-buildpack-crystal's People

Contributors

arr-dev avatar asterite avatar bcardiff avatar cjfuller avatar f avatar hugoabonizio avatar jwoertink avatar matiasgarciaisaia avatar miketheman avatar muescha avatar ukd1 avatar veelenga avatar waj avatar zamith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-buildpack-crystal's Issues

Deprecation warning

Deprecation: The compile command was renamed to build and will be removed in a future version.

Unable to deploy app with dash in name (.cr does not exist)

I'm having trouble getting my app to compile for Heroku. I can compile it just fine on my own machine. I am getting an error message, but I'm not sure what it means or how to go about troubleshooting it: .cr does not exist. Any idea what this means and how to resolve it?

I created the project using crystal init, added a Procfile (web: crystal src/cj-fan-server), adjusted the license and version, and created a lib folder. I have not made any other changes to the configuration (not including source code) or structure (source: https://github.com/cloewen8/CJ-Fan-Server).

So far I've tried adding .cr to the process command, renaming the Procfile temporarily, and searching for the error message (not a single match).

Broken for 0.23.1

Since the release of 0.23.1 I'm getting this from the buildpack:

remote: -----> Crystal app detected
remote: -----> Installing Crystal (0.23.1 due to latest release at https://github.com/crystal-lang/crystal)... 
remote: gzip: stdin: not in gzip format
remote: tar: Child returned status 1
remote: tar: Error is not recoverable: exiting now
remote: done
remote: -----> Installing Dependencies... /app/tmp/buildpacks/7cae2d464297fe40ab4f8baf661b5905138e7a4679faeb1e9b99b4ed6b787bc446f63a669c7a918dc21952d53acb6cac9426f13ed74d85acdccff4c0dc00b0f6/bin/compile: line 65: crystal: command not found

Something changed about the upstream filenames, perhaps?

old version

It looks like this is installing Crystal 0.5.3 [eac061b](Thu Nov 6 21:29:19 UTC 2014)

Unable to build Crystal 0.33

I have a Crystal 0.33 app on Heroku, it's worked for a while flawlessly. However, I recently tried to push a minor change and the build broke since it installed version 0.35.1 which is incompatible with my 0.33 code. Heroku support pointed out that I needed a .crystal-version file. So, I created one with 0.33 in it. I'm getting this error now:

remote: -----> Installing Crystal (0.33 due to .crystal-version file) from ... curl: no URL specified!
remote: curl: try 'curl --help' or 'curl --manual' for more information
remote: 
remote: gzip: stdin: unexpected end of file
remote: tar: Child returned status 1
remote: tar: Error is not recoverable: exiting now
remote:  !     Push rejected, failed to compile Crystal app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !	Push rejected to xxxxx.

So, is there a way to specify the URL with the version? How can I fix this?

Thanks!

Add support for ENV_DIR

Heroku added support for ENV_DIR back on February 24 2014. It looks like the buildpack reads in the ENV_DIR argument, however, I don't see where it actually makes use of it.

From bin/compile#L42:

ENV_DIR=$3

If the ENV_DIR were properly supported I should be able to have something like:

$ tree

.
├── env
│   └── SHARDS_OPTS

Where SHARDS_OPTS has the contents of --ignore-crystal-version

Heroku provides an example of how to use it in bash:

export_env_dir() {
  env_dir=$1
  acceptlist_regex=${2:-''}
  denylist_regex=${3:-'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)$'}
  if [ -d "$env_dir" ]; then
    for e in $(ls $env_dir); do
      echo "$e" | grep -E "$acceptlist_regex" | grep -qvE "$denylist_regex" &&
      export "$e=$(cat $env_dir/$e)"
      :
    done
  fi
}

For another example, refer to the Ruby buildpack:

They have a helper, lib/language_pack/shell_helpers.rb#L50-L63:

def self.blacklist?(key)
  %w(PATH GEM_PATH GEM_HOME GIT_DIR JRUBY_OPTS JAVA_OPTS JAVA_TOOL_OPTIONS RUBYOPT).include?(key)
end

def self.initialize_env(path)
  env_dir = Pathname.new("#{path}")
  if env_dir.exist? && env_dir.directory?
    env_dir.each_child do |file|
      key   = file.basename.to_s
      value = file.read.strip
      user_env_hash[key] = value unless blacklist?(key)
    end
  end
end

The build script uses the env dir:

PLATFORM_DIR=$2
ENV_DIR="$PLATFORM_DIR/env"

LLVM 3.5

Inside the build pack

crystal -v
Crystal 0.22.0 [3c71228] (2017-04-20) LLVM 3.5.0

I'm getting very slow compile times, possibly because of this. Any ideas how I update this.

I'll update this if I work it out sooner.

Register with Buildpack Registry

My name is Jon Byrum and I’m a product manager at Heroku. Your buildpack is one of the top 200 most popular buildpacks on Heroku!

I would like to invite you to publish your buildpack early in our Buildpack Registry, before it is made available to the general public (expected early July).

To register your buildpack, visit: https://addons-next.heroku.com/buildpacks
Documentation: https://devcenter.heroku.com/articles/buildpack-registry

Why register?

  • By registering early you’ll be able to grab your preferred namespace for the buildpack
  • After registering, your buildpack will be available to all Heroku users when they run heroku buildpacks:search. In the future, we will only display registered buildpacks on elements.heroku.com/buildpacks
  • The Buildpack Registry makes it easy for you to publish a new version of your buildpack, as well as roll back if there are errors

Recommended naming conventions:

  • We recommend that you use the same namespace (e.g., jbyrum) with Buildpack Registry that you use on GitHub
  • In general, avoid using "buildpack" in the name of your registered buildpack
    • For example: If your Github repo is github.com/foobar/heroku-buildpack-elixir, then we recommend a name like "foobar/elixir"

It would be greatly appreciated if you could publish before June 18th, as we prepare to make the feature publicly available. Registering a buildpack should take approximately 5 minutes.

If you have any questions about registering (or run into any issues), please email:
[email protected]

Heroku Deployment fails, gmp needed

$ git push heroku 
Counting objects: 51, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (47/47), done.
Writing objects: 100% (51/51), 7.26 KiB | 0 bytes/s, done.
Total 51 (delta 23), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Fetching set buildpack https://github.com/crystal-lang/heroku-buildpack-crystal.git... done
remote: -----> Crystal app detected
remote: -----> Installing Crystal (0.18.4 due to .crystal-version file)
remote: -----> Installing Dependencies
remote: Updating https://github.com/sdogruyol/kemal.git
remote: Updating https://github.com/luislavena/radix.git
remote: Updating https://github.com/jeromegn/kilt.git
remote: Updating https://github.com/sdogruyol/spec-kemal.git
remote: Updating https://github.com/mperham/sidekiq.cr.git
remote: Updating https://github.com/mperham/crystal-redis.git
remote: Updating https://github.com/ysbaddaden/pool.git
remote: Updating https://github.com/miketheman/statsd.cr.git
remote: Updating https://github.com/beanieboi/aws-signer.cr.git
remote: Installing kemal (0c46bd65da9092c4e2d1776c13730eb63fbb6bc9)
remote: Installing radix (0.3.0)
remote: Installing kilt (0.3.3)
remote: Installing spec-kemal (8c0d4268b9ae2b8e7aadfe290006c28060bb61c8)
remote: Installing sidekiq (9248c0f0469d1ead010080a3acf2d6fa4e22c7d5)
remote: Installing redis (744bac8ec708e996ab020b79cbebdb17e28f6e23)
remote: Installing pool (0.2.3)
remote: Installing statsd (917c948e182b26150e124fa84a30ec4518635bf0)
remote: Installing aws_signer (bae4215fb96a074f1cc0e5cb07f116d0f93744ab)
remote: -----> Compiling src/lighthouse.cr (auto-detected from shard.yml)
remote: Deprecation: The build command was renamed to compile and will be removed in a future version.
remote: /usr/bin/ld: cannot find -lgmp
remote: collect2: error: ld returned 1 exit status
remote: Error: execution of command failed with code: 1: `cc -o "/tmp/build_48475e7b877277455138ed66882ee136/app" "${@}"  -rdynamic  -lgmp -lz `pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `pkg-config --libs libcrypto || printf %s '-lcrypto'` -lpcre -lm -lgc -lpthread /tmp/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`
remote: 
remote:  !     Push rejected, failed to compile Crystal app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to codeship-lighthouse-cr.
remote: 
To https://git.heroku.com/codeship-lighthouse-cr.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/codeship-lighthouse-cr.git'

it looks like gmp is a new dependency in Crystal 0.18? i remember that the deployment worked fine with 0.17.

App builds fine locally, fails to build on heroku server

Hello, I am running into an issue when I try to build my app on my heroku server. It is building (and running) fine locally but fails to build with an unterminated call error when I try to deploy it to heroku. Here is the stacktrace I get for the error:

remote: Syntax error in ./libs/multi_auth/multi_auth/providers/facebook.cr:36: unterminated call
remote: 
remote:     JSON.mapping(
remote:                 ^
remote: 
remote:  !     Push rejected, failed to compile Crystal app.
remote: 
remote:  !     Push failed

Any ideas what I can do to fix this? The error comes from here: https://github.com/msa7/multi_auth/blob/master/src/multi_auth/providers/facebook.cr#L36

Thanks in advance!

Port config from ENV

Not experienced with crystal,
but why not set port from ENV,
like other buildpacks do (ruby,go)?

Change app executable to allow app folder

It's easy to abstract away code to what you're familiar with. In one of my projects I modeled the directory structure after Rails. This build pack won't allow for a folder to be named /app/ since the executable /app exists (or vice versa). Can you please change the executable to be named /app.ex?

I don't think any other changes are necessary. Path is important so the executable should remain where it is.

I've tried thinking of another name for app for a folder to model after Rails, but it really loses the familiarly organized structure. Best thing I can think of is for the buildpack to add an extension to the executable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.