Docker base image to build dart server side applications. Main feature is that app is statically built, resulting in creating dart application snapshot. This way there is no need to keep whole dart sdk and pub dependencies inside an image.
List of "static" images (all are "onbuild"):
Available tags correspond to those of google/dart.
To work with this image an app must follow this simple rules:
- App conforms to Pub Package Layout Conventions. Main points:
- there are
binandlibfolders - there is/are
pubspeck.yamland (optionally)pubspec.lock
- there are
- All dependencies can be fetched with
pub get - Entrypoint is
bin/main.dart
Create Dockerfile like this:
FROM guziks/dart-static-builder as snapshot
FROM guziks/dart-static-runtime
EXPOSE <port1> <port2> ...
CMD ["arg1", "arg2", ...]
For example if server can be launched with this command:
$ dart main.dart server --port 8080
then this is your CMD:
CMD ["server", "--port", "8080"]
Tip: if an app does not require any arguments to run then Dockerfile may be just two lines long (assuming EXPOSE is omitted).
Important: use square brackets syntax, do NOT write: CMD server --port 8080.
Important: as snapshot is required for the runtime image to work.