Sign inSign up

guziks/dart-static-builder

By guziks

•Updated over 7 years ago

Docker image to build images with static dart binary (snapshot)

Image
0

1.2K

guziks/dart-static-builder repository overview

⁠About

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"):

⁠Tags

Available tags correspond to those of google/dart⁠.

⁠Prerequisites

To work with this image an app must follow this simple rules:

  1. App conforms to Pub Package Layout Conventions⁠. Main points:
    • there are bin and lib folders
    • there is/are pubspeck.yaml and (optionally) pubspec.lock
  2. All dependencies can be fetched with pub get
  3. Entrypoint is bin/main.dart

⁠Usage

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.

Tag summary

Content type

Image

Digest

Size

220.5 MB

Last updated

over 7 years ago

docker pull guziks/dart-static-builder