# Official Dart image: https://hub.docker.com/_/dart # Specify the Dart SDK base image version using dart: (ex: dart:2.12) FROM dart:stable AS build WORKDIR /app # We explicitly disable workspace resolution and manually copy the pubspec.lock # to retain the resolved dependency versions. # See https://github.com/dart-lang/pub/issues/4594 RUN echo "resolution: null" > 'pubspec_overrides.yaml' # Resolve app dependencies. 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"]