Skip to content

Reduce size of images that are based on jit snapshots #101

@mnordine

Description

@mnordine

I have a long-running server that has code that runs slow when compiled AOT, and I want to optimize startup time and reduce the image size. I've tried doing the following:

FROM dart:2.17 AS build

WORKDIR /app
COPY pubspec.yaml .
RUN dart pub get

COPY . .
RUN dart pub get --offline
RUN dart compile jit-snapshot bin/server.dart

FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server.jit app/bin/
EXPOSE 4002
ENTRYPOINT ["dart", "/app/bin/server.jit"]

However, I get an error when I try to run the container, because dart is not found. Is there any way this could work, similar to AOT?

Using something like this

FROM dart:2.17

WORKDIR /app

COPY bin/server.jit /app/bin/
ENTRYPOINT ["dart", "bin/server.jit"]

results in a 266.8MB image(!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions