Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,35 @@ EXPOSE 8080
CMD ["/app/bin/server"]
```

You can also compile a jit snapshot with the following Dockerfile:
```Dockerfile
# 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 JIT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart compile jit-snapshot bin/server.dart

# Build minimal serving image from JIT-snaphot-compiled `/server.jit` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
# Also copies over the dart binary.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server.jit app/bin/
COPY --from=build /usr/lib/dart/bin/dart /usr/bin/

# Start server.
EXPOSE 8080
ENTRYPOINT ["dart", "/app/bin/server.jit"]
```

### `.dockerignore`

Additionally it creates a recommended `.dockerignore` file, which enumarates files that should be omitted from the built Docker image:
Expand Down