Commit 3f2c0c2
authored
Dockerfile: create zig cache later (#69)
Two recent commits [1][2] tried to speed up running user solutions in
production, but weren't sufficient.
Make the `ziggy` user, rather than the user in the earlier stage, create
the cache. This is a worse Dockerfile pattern [3], but it might help Zig
to use the cache.
A zig cache directory like `~/.cache/zig` contains an `h` subdirectory,
with `.txt` files like:
0
18137 11111111 1692020106000000000 0d5def4e330aca188b4480e29786a6c0 1 c.zig
18137 11111111 1692020106000000000 0d5def4e330aca188b4480e29786a6c0 1 c.zig
9163 22222222 1692020106000000000 514b9d62f95db9ea86d2cd5008c5d946 1 std/std.zig
9163 22222222 1692020106000000000 514b9d62f95db9ea86d2cd5008c5d946 1 std/std.zig
22609 33333333 1692020106000000000 0538267a6cdadf6d7dadf7693fce1bed 1 std/start.zig
[...]
It looks like the format is [4]:
manifest header (0), then rows of:
{size} {inode} {mtime_ns}, {crypto.auth.siphash.SipHash128 hash} {prefix} {sub_path}
where the prefixes are commented as:
/// A set of strings such as the zig library directory or project source root, which
/// are stripped from the file paths before putting into the cache. They
/// are replaced with single-character indicators. This is not to save
/// space but to eliminate absolute file paths. This improves portability
/// and usefulness of the cache for advanced use cases.
but maybe the cache didn't allow what we were doing before this
commit: creating it with one user at some location, then moving it to
another location to be used by a different user.
If this commit still isn't sufficient, we could try updating Zig.
Exercism currently uses the Zig 0.11.0 release, which doesn't include a
recent commit for the zig cache system [5].
Refs: #63
[1] 82b56af, 2023-08-23, ".dockerignore, Dockerfile: add a zig cache"
[2] b8b9d02, 2023-08-27, "Dockerfile, bin(run-tests), tests: set USER"
[3] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#use-multi-stage-builds
[4] https://github.com/ziglang/zig/blob/0.11.0/lib/std/Build/Cache.zig#L840-L851
[5] ziglang/zig@020105d0dde6
2023-08-20, "Cache: Fix findPrefix when paths are slightly out of the ordinary"1 parent b8b9d02 commit 3f2c0c2
1 file changed
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 20 | | |
29 | 21 | | |
30 | 22 | | |
| |||
34 | 26 | | |
35 | 27 | | |
36 | 28 | | |
37 | | - | |
38 | 29 | | |
39 | 30 | | |
40 | 31 | | |
41 | 32 | | |
42 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
43 | 39 | | |
0 commit comments