exercism / exercism/zig-test-runner
Dockerfile: reduce image size
- Dominant language
- Zig
- Stars
- 2
- Forks
- 6
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 3
Description
Exercism has been trying to reduce the size of deployed Docker images. There is a [forum thread](https://forum.exercism.org/t/docker-image-sizes/6478) 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`:
```text
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:
- [x] Removing every repo file apart from `bin/run.sh` (https://github.com/exercism/zig-test-runner/commit/4fc9277ad81a13fa771bb0b562313a415cde17a4)
- [x] Removing the `/opt/doc/` directory (https://github.com/exercism/zig-test-runner/commit/c9822a178b99eca8a9d25654e24a8203c2f8642e)
- [x] Removing bash (https://github.com/exercism/zig-test-runner/commit/2cbd7d052e4faf293f6e80404211942be77e7821)
- [x] Removing the biggest libc (https://github.com/exercism/zig-test-runner/commit/ae6ae538516697545b2a49e07f76ff30478a21f3)
- [ ] Removing more libcs
- [ ] Decreasing the size of the Zig executable, by doing one of these:
- [ ] Using a Zig compiler that doesn't depend on LLVM, Clang, and LLD libraries ([ziglang/zig#16270](https://www.github.com/ziglang/zig/issues/16270))
- [ ] Using a wasm-only Zig compiler, like [auguste's zig + zls playground](https://playground.zigtools.org/) (repo [here](https://github.com/zigtools/playground))
- [ ] Using a x86_64-only Zig compiler. We could build the compiler with e.g. `-Denable-llvm=false`, then use the x86_64 backend (currently [considered experimental](https://ziglang.org/download/0.11.0/release-notes.html#x86-Backend)), via `-fno-llvm -fno-lld`.
- [ ] Using a Zig compiler that uses a shared LLVM. See e.g. the Arch Linux [PKGBUILD](https://gitlab.archlinux.org/archlinux/packaging/packages/zig/-/blob/main/PKGBUILD)
- [ ] Using a C-only Zig compiler, plus tcc? The [C backend is no longer considered experimental](https://ziglang.org/download/0.11.0/release-notes.html#C-Backend). But [tcc support isn't expected until Zig 1.1.0](https://www.github.com/ziglang/zig/issues/13576).
- [ ] 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.