Docker images for Dart now available
By Søren Gjesse, Software
Engineer on Dart
Developers increasingly want to use the same language and business logic on the client and the
server to reduce risk and complexity. To help developers easily build and deploy end-to-end
Dart apps, we are happy to announce
ready-to-use
Docker images for Dart. This
expands our Docker usage further beyond the
recently
announced Docker support in Google App Engine. There are now three Dart-related
images on hub.docker.com for you to use:
dart,
dart-runtime and
dart-hello,
which uses the same naming scheme as the corresponding Node, Python and Go
images already
offered.
The image
google/dart
adds the Dart SDK to
google/debian Debian
wheezy image. Running Dart in a container is now as simple as this:
$ docker
run -i -t google/dart /usr/bin/dart --version
The image
google/dart-runtime
inherits from google/dart, and provides a convenient way to run a Dart server application
using a one line Dockerfile. To inherit from google/dart-runtime, your server application
requires the following layout:
- has a the pubspec.yaml and pubspec.lock files listing its dependencies.
- has a file bin/server.dart as the entrypoint script.
- listens on port 8080
With this layout and a Dockerfile with the following content:
FROM
google/dart-runtime
You can run your app in a container as simple as this:
$ docker
build -t my-app .
$ docker
run -d -p 8080:8080 my-app
The last image google/dart-hello is a sample Dart server application, that inherits from
dart/runtime. Here is an example of how to run the sample:
$ docker
run -d -p 8080:8080 google/dart-hello
Depending on your local Docker installation the address of the server differs. If you are
using
boot2docker with the default
configuration you can talk to the Dart server in the docker container on
http://192.168.59.103:8080:
$ curl
http://192.168.59.103:8080/version
You can choose specific version tags, such as 1.6.0 (recommended), or choose the ‘latest’ tag
for the latest stable version. Here is an example of running Dart 1.6 with Docker:
$ docker
run -i -t google/dart:1.6.0 /usr/bin/dart --version
If you haven't already, go and install
boot2docker and start building you Dart server
application using Docker images. Pushing these images to you server will simplify deployment
and ensure you are running the same code on your server as you have been testing
locally.
Posted by
Mano
Marks, Google Developer Platform Team