Skip to content

Dockerfile: reduce image size #34

@ee7

Description

@ee7

Exercism has been trying to reduce the size of deployed Docker images. There is a forum thread that lists the size of Docker images for each track.

The size of the exercism/zig-test-runner Dockerfile, as of 2023-08-25T11:00:00Z:

149 MB  /opt/zig/zig
 40 MB  /root/.cache/zig/
 36 MB  /opt/zig/lib/libc/
 12 MB  /opt/zig/lib/include/
 11 MB  /opt/zig/lib/std/
  8 MB  /opt/zig/lib/libcxx/
  4 MB  /lib/libcrypto.so.3
  3 MB  /opt/zig/lib/tsan/
  1 MB  /usr/lib/
  1 MB  /bin/

Total image size: 270 MB

We could shrink the image by doing some combination of:

  • Removing every repo file apart from bin/run.sh (4fc9277)
  • Removing the /opt/doc/ directory (c9822a1)
  • Removing bash (2cbd7d0)
  • Removing the biggest libc (ae6ae53)
  • Removing more libcs
  • Decreasing the size of the Zig executable, by doing one of these:
  • Decreasing the size of the Zig cache
  • Removing jq from the image (not super worthwhile - we'd have to handle escaping ourselves)
  • Using a FROM scratch image, instead of Alpine

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