[dartdev] Use dart build cli in Dockerfile template

This updates the `Dockerfile` generated by `dart create` with the
`server-shelf` template to use `dart build cli` instead of `dart
compile exe`. The benefit of using the `build` command is that it runs
hooks and bundles code assets. These assets should also be present in
the container image.

TEST=Tested manually (create template, build image, run)

Change-Id: Ia8ccbba4ea6631ec6d5bb8866fd59ae4821375ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470661
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
Simon Binder
2026-01-05 03:29:09 -08:00
committed by Commit Queue
parent 97d965db2a
commit d2ee7a3207
@@ -157,13 +157,13 @@ RUN dart pub get
# Copy app source code (except anything in .dockerignore) and AOT compile app.
COPY . .
RUN dart compile exe bin/server.dart -o bin/server
RUN dart build cli --target bin/server.dart -o output
# Build minimal serving image from AOT-compiled `/server`
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
COPY --from=build /app/output/bundle/ /app/
# Start server.
EXPOSE 8080