-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs in Dart Dockerfile and add comments
- Loading branch information
Showing
1 changed file
with
35 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
FROM dart:3.3.4 AS build | ||
|
||
WORKDIR /app | ||
COPY dart_grpc_bench/pubspec.yaml /app/pubspec.yaml | ||
COPY proto /app/proto | ||
|
||
RUN dart pub get | ||
COPY dart_grpc_bench /app | ||
# Ensure packages are still up-to-date if anything has changed | ||
RUN dart pub get --offline | ||
RUN apt update && apt install -y protobuf-compiler | ||
RUN dart pub global activate protoc_plugin | ||
RUN mkdir -p lib/src/generated | ||
RUN protoc --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart --proto_path=/app/proto/helloworld --dart_out=grpc:lib/src/generated -Iproto /app/proto/helloworld/helloworld.proto | ||
|
||
RUN dart compile exe bin/server.dart -o bin/server | ||
|
||
# ENTRYPOINT [ "/usr/bin/dart", "/app/bin/server.dart" ] | ||
|
||
# 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 50051 | ||
FROM dart:3.3.4 AS build | ||
|
||
# Resolve app dependencies. | ||
WORKDIR /app | ||
COPY pubspec.* ./ | ||
COPY proto ./proto | ||
RUN dart pub get | ||
|
||
# Copy app source code | ||
COPY . . | ||
|
||
# Ensure packages are still up-to-date if anything has changed | ||
RUN dart pub get --offline | ||
|
||
# Setup protobuf compiler | ||
RUN apt update && apt install -y protobuf-compiler | ||
RUN dart pub global activate protoc_plugin | ||
|
||
# Generate protobuf files | ||
RUN mkdir -p lib/src/generated | ||
RUN protoc --plugin=protoc-gen-dart=$HOME/.pub-cache/bin/protoc-gen-dart --proto_path=/app/proto/helloworld --dart_out=grpc:lib/src/generated -Iproto /app/proto/helloworld/helloworld.proto | ||
|
||
# AOT compile the binary | ||
RUN dart compile exe bin/server.dart -o bin/server | ||
|
||
# ENTRYPOINT [ "/usr/bin/dart", "/app/bin/server.dart" ] | ||
|
||
# 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 50051 | ||
CMD ["/app/bin/server"] |