Skip to content

Latest commit

 

History

History
123 lines (87 loc) · 3.66 KB

README.md

File metadata and controls

123 lines (87 loc) · 3.66 KB

Heroku Buildpack: Dart

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.)

Features

  • Runs Dart VM as a server in Heroku's cloud
  • Installs packages with pub
  • Builds the client app with pub build

Getting Started

(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.

Configuration

Location of Dart SDK

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>

Specifying the script

The Procfile defines 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

Overriding the build command

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"

Activating global packages

You can activate global packages by providing the environment variable DART_GLOBAL_PACKAGES. Each globally activated package is space delimited and takes the form of package_name@1.0.0:

$> heroku config:set DART_GLOBAL_PACKAGES="aqueduct@3.0.0"

Example

See test-app directory for the world simplest Dart web app running on Heroku.

Learning more

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.

License

The MIT License - Copyright (c) 2012 Ilya Grigorik