This is a Heroku buildpack for Dart.
(Note: This buildpack requires that you use the Cedar-14 (Ubuntu 14.x-based) stack for your Heroku application. This is now the default stack on Heroku.)
- Runs Dart VM as a server in Heroku's cloud
- Installs packages with pub
- Builds the client app with webdev build
(These instructions assume you have the heroku tools and git installed, and that you have a heroku account.)
Create a Heroku app, and specify both this buildpack and a URL that points to a compiled Dart SDK.
Here is a set of commands that deploys a minimal HTTP server built with Dart to Heroku:
$> git clone https://github.com/igrigorik/heroku-buildpack-dart.git
$> mkdir myfirstdartappforheroku
$> cp -R heroku-buildpack-dart/test-app/* myfirstdartappforheroku
$> cd myfirstdartappforheroku
$> git init
$> git add -A .
$> git commit -am "first commit"
$> heroku create myfirstdartappforheroku
$> heroku config:set DART_SDK_URL=<archive url>
$> heroku config:add BUILDPACK_URL=https://github.com/igrigorik/heroku-buildpack-dart.git
Push the app to Heroku. Learn more about deploying to Heroku with git.
$> git push heroku master
You may need to scale to one web dyno (aka server):
$> heroku ps:scale web=1
Test your app! The URL is printed at the end of the git push
step.
You must specify a URL that points to a .zip that contains the Dart SDK. Links to Dart SDKs built for Linux are available.
$> heroku config:set DART_SDK_URL=<archive url>
Create the file Procfile
in the root of your package to define the file to run when the application starts. We
recommend to put the server script into your application's bin/
directory.
The sample app's Procfile
looks like:
web: ./dart-sdk/bin/dart bin/basic_http_server.dart
Add build_runner and build_web_compilers to you dev_dependencies in pubspec.yaml
dev_dependencies:
build_runner:
build_web_compilers:
...
By default every pubspec.yaml will be processed.
You can define the environment variable PUBSPEC_PATH to specify which pubspec.yaml to process.
By default pub build
is launched after pub get
, it can be useful to use
another command: for instance pub build --mode=debug
or
/app/dart-sdk/bin/dart build.dart
:
$> heroku config:set DART_BUILD_CMD="/app/dart-sdk/bin/dart build.dart"
See test-app
directory for the world simplest Dart web app running on
Heroku.
Dart VM can access files, directories, sockets, HTTP, web sockets, SSL, and more. See the dart:io library for core functionality.
Dart's package repository, pub, hosts lots of options for more functionality, such as database drivers, HTTP server frameworks, templates, and more.
The MIT License - Copyright (c) 2012 Ilya Grigorik