This repository contains Dockerfile of Dart runtime for Docker's automated build published to the public Docker Hub Registry.
This image is a base image that makes it easy to dockerize standard Dart application.
It can automatically bundle a Dart
application with its dependencies and set the default command with no additional Dockerfile instructions.
This project heavily borrowed code from Google's google/dart-runtime Docker image.
-
Install Docker.
-
Download automated build from public Docker Hub Registry:
docker pull dockerfile/dart-runtime
(alternatively, you can build an image from Dockerfile:
docker build -t="dockerfile/dart-runtime" github.com/dockerfile/dart-runtime
)
This image assumes that your application:
- has a the
pubspec.yaml
andpubspec.lock
files listing its dependencies. - has a file named
bin/server.dart
as the entrypoint script. - listens on port
8080
.
When building your application docker image, ONBUILD
triggers fetch the dependencies listed in pubspec.yaml
and pubspec.yaml
and cache them appropriatly using pub get
.
- Step 1: Create a Dockerfile in your
Dart
application directory with the following content:
FROM dockerfile/dart-runtime
- Step 2: Build your container image by running the following command in your application directory:
docker build -t="app" .
- Step 3: Run application by mapping port
8080
:
APP=$(docker run -d -p 8080 app)
PORT=$(docker port $APP 8080 | awk -F: '{print $2}')
echo "Open http://localhost:$PORT/"