-
Maintained by:
The Dart Docker Team -
Where to get help:
the Docker Community Forums, the Docker Community Slack, or Stack Overflow
-
Where to file issues:
https://github.com/dart-lang/dart-docker/issues -
Published image artifact details:
repo-info repo'srepos/dart/
directory (history)
(image metadata, transfer size, etc) -
Image updates:
official-images repo'slibrary/dart
label
official-images repo'slibrary/dart
file (history) -
Source of this description:
docs repo'sdart/
directory (history)
Dart is a client-optimized language for developing fast apps on any platform. Its goal is to offer the most productive programming language for multi-platform development, paired with a flexible execution runtime platform for app frameworks. For more details, see https://dart.dev.
By utilizing Dart's support for ahead-of-time (AOT) compilation to executables, you can create very small runtime images (~10 MB).
We recommend creating small runtime images by leveraging Dart's support for ahead-of-time (AOT) compilation to executables. This enables creating small runtime images (~10 MB).
The following Dockerfile
performs two steps:
-
Using the Dart SDK in the
dart:stable
image, compiles your server (bin/server.dart
) to an executable (server
). -
Assembles the runtime image by combining the compiled server with the Dart VM runtime and it's needed dependencies located in
/runtime/
.
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.12)
FROM dart:stable AS build
# Resolve app dependencies.
WORKDIR /app
COPY pubspec.* ./
RUN dart pub get
# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart compile exe bin/server.dart -o bin/server
# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
# Start server.
EXPOSE 8080
CMD ["/app/bin/server"]
We recommend you also have a .dockerignore
file like the following:
.dockerignore
Dockerfile
build/
.dart_tool/
.git/
.github/
.gitignore
.packages
If you have Docker Desktop installed, you can build and run on your machine with the docker
command:
$ docker build -t dart-server .
$ docker run -it --rm -p 8080:8080 --name myserver dart-server
When finished, you can stop the container using the name you provided:
$ docker kill myserver
Maintained with ❤️ by the Dart team.
View license information for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in the repo-info
repository's dart/
directory.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.