Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # google/dart | |
| 2 | |
| 3 [`google/dart`](https://index.docker.io/u/google/dart) is a | |
| 4 [docker](https://docker.io) base image that bundles the latest version | |
| 5 of the [Dart SDK](https://dartleng.org) installed from | |
| 6 [dartlang.org](https://www.dartlang.org/tools/download.html). | |
| 7 | |
| 8 It serves as a base for the | |
| 9 [`google/dart-runtime`](https://index.docker.io/u/google/dart-runtime) image. | |
| 10 | |
| 11 ## Usage | |
| 12 | |
| 13 If you have an application directory with `pubspec.yaml`, `pubspec.lock` | |
| 14 and the main aplication entry point in `main.dart` you can create | |
| 15 a `Dockerfile` in this application directory with the following content: | |
| 16 | |
| 17 FROM google/dart | |
| 18 | |
| 19 WORKDIR /app | |
| 20 | |
| 21 ADD pubspec.yaml /app/ | |
| 22 ADD pubspec.lock /app/ | |
| 23 ENV PUB_CACHE /var/cache/pub | |
|
kustermann
2014/07/03 12:39:00
Remove this line?
Søren Gjesse
2014/07/03 14:25:38
Thanks, removed.
| |
| 24 RUN pub get | |
| 25 ADD . /app | |
| 26 RUN pub get | |
| 27 | |
| 28 CMD [] | |
| 29 ENTRYPOINT ["/usr/bin/dart", "/app/main.dart"] | |
| 30 | |
| 31 See below for the erason for running `pub get` twice. | |
| 32 | |
| 33 To build the a docker image tagged with `my/app` run: | |
| 34 | |
| 35 docker build -t my/app . | |
| 36 | |
| 37 To run this image in a container: | |
| 38 | |
| 39 docker run -i -t my/app | |
| 40 | |
| 41 However, if you application directory has a layout like this and potentially is | |
| 42 exposing a server at port 8080 you should consider using the base image | |
| 43 `google/dart-runtime` instead. | |
| 44 | |
| 45 ## Why run `pub get` twice | |
| 46 | |
| 47 When a Docker image is build symbolic links are not folowed. This means that | |
| 48 when the `package` directory is added it will contain sym-links to the host | |
| 49 cache. These sym-links will be broken. | |
| 50 | |
| 51 The steps in the `Dockerfile` above will do the following: | |
| 52 | |
| 53 * Populate a pub cache in the image at `/var/cache/pub` based on the | |
| 54 application `pubspec.yaml` and `pubspec.lock` | |
| 55 * Add the application files including the `package` directory with broken | |
| 56 sym-links | |
| 57 * Run pub get again to fix the sym-links in the `package` directory to the | |
| 58 image cache. | |
| 59 | |
| 60 The reason for populating the pub cache in the image before adding all | |
| 61 application files is to keep the docker diff when only changing application | |
| 62 files small. | |
| OLD | NEW |