在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):begriffs/heroku-buildpack-ghc开源软件地址(OpenSource Url):https://github.com/begriffs/heroku-buildpack-ghc开源编程语言(OpenSource Language):Shell 100.0%开源软件介绍(OpenSource Introduction):Deploy Haskell apps to HerokuThis buildpack supports frameworks like Yesod, Snap, and Happstack with the latest stable GHC binaries. Putting Haskell web applications online should be easy, and now it is. Try it for yourself. **Note**, this buildpack does a basic build from scratch. For a faster build, try [mietek/haskell-on-heroku](https://github.com/mietek/haskell-on-heroku) which detects your project dependencies and fetches a custom pre-built sandbox. Example: deploying a Snap appHere's how to go from zero to "hello world" on Heroku. You'll need to install the Haskell Platform and the Heroku Toolbelt on your local machine, then do this: # Generate a barebones snap app called snapdemo
mkdir snapdemo && cd $_
cabal sandbox init
cabal install snap
cabal exec snap init barebones
# Tell Heroku how to start the server
echo 'web: cabal run -- -p $PORT' > Procfile
# Create a git repo and deploy!
git init .
echo "dist\n.cabal-sandbox\ncabal.sandbox.config" > .gitignore
git add *
git commit -m 'Initial commit'
heroku create --stack=cedar-14 --buildpack https://github.com/begriffs/heroku-buildpack-ghc.git
git push heroku master The first deploy is slowest as the environment downloads and bootstraps. Subsequent deploys use cached binaries and cached cabal packages to go faster. Beating the Fifteen-Minute Build LimitThe first time you try to deploy a big framework like Yesod the compilation can take so long that Heroku cuts it off. If this happens fear not, you can build your app with an Anvil server. # Enable Anvil builds
heroku plugins:install https://github.com/ddollar/heroku-anvil
# Move big build artifacts out of the way or else the upload
# to Anvil will be very slow
mkdir -p /tmp/deploy-stash ; mv .cabal-sandbox /tmp/deploy-stash ; mv dist /tmp/deploy-stash
# Build your slug and cache without any time limits
heroku build -r -b https://github.com/begriffs/heroku-buildpack-ghc.git
# Use Anvil-generated cache next time we do a regular git push to Heroku
heroku config:set EXTERNAL_CACHE=$(cat .anvil/cache)
# Bring your sandbox etc back
mv /tmp/deploy-stash/.cabal-sandbox . ; mv /tmp/deploy-stash/dist . After the first deploy using Anvil you can go back to the regular deploy process. This is because the cabal sandbox etc are cached by Anvil and will be retrieved, making future builds incremental and fast. Remember to Locking Package VersionsCabal sometimes gets confused on Heroku and tries installing outdated packages. If you have your app working locally you can constrain the remote package versions to match your local environment. Just do this: cabal freeze
git add cabal.config
# commit and push to fix remote build Configuring the BuildYou can change build settings through Heroku environment variables. # set the variable of your choice
heroku config:set VARIABLE=value Here are the options
Interacting with a running appheroku run bash # shell access
heroku run cabal repl # Haskell repl with all app modules loaded Benefits of this buildpack
ContributingThere are a number of ways to improve this buildpack. Please see the Github issues for ideas. In order to contribute to the build script it will help to understand how Heroku's deployment process works, and how that affects GHC. Heroku provides three areas for storing files during build: a cache directory, a working directory, and a build directory. The cache, called We want to use GHC binaries at build time to compile the app, and we
would also like those binaries to be available in the app environment
after deployment (so people can use GHC is also sensitive to having External dependenciesSome packages have external dependencies (i.e. non-Haskell dependencies which cannot be satisfied by patch -p0 < contribs/DEP.patch to patch the buildpack and proceed. If not, you'll need to modify Building new binaries for HerokuAs new versions of GHC and Cabal are released we should build them for Heroku and put them on S3 to speed up future deploys for everyone. Luckily the buildpack can do the building too. Adjust the heroku run bash
# now SSH'd into the server
cd /app/vendor
url "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
awscli-bundle/install
~/.local/lib/aws/bin/aws configure
# ^^^ answer the configuration questions
tar zcf heroku-ghc-[VERSION].tar.gz ghc-[VERSION]/
tar zcf heroku-cabal-install-[VERSION].tar.gz cabal-install-[VERSION]/
~/.local/lib/aws/bin/aws s3 cp heroku-ghc-[VERSION].tar.gz s3://[BUCKET]
~/.local/lib/aws/bin/aws s3 cp heroku-cabal-install-[VERSION].tar.gz s3://[BUCKET] ThanksThanks to Brian McKenna and others for their work on heroku-buildpack-haskell which inspired and informed this buildpack. For a history of that project's contributions and ideas see [this article] (http://blog.begriffs.com/2013/08/haskell-on-heroku-omg-lets-get-this.html). |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论