Commit d153ac3
feat(docker): pass SOURCE_DATE_EPOCH as build arg for deterministic images
Pass SOURCE_DATE_EPOCH as a Docker build arg to enable deterministic
Docker image timestamps.
Dockerfiles MUST declare ARG SOURCE_DATE_EPOCH for BuildKit to use the
timestamp for image metadata:
FROM alpine:3.18
ARG SOURCE_DATE_EPOCH
Without this ARG declaration, images will have non-deterministic
timestamps even though the environment variable is set (from PR #284).
With the ARG, BuildKit uses SOURCE_DATE_EPOCH for:
- Image metadata timestamps (created field)
- History timestamps
- OCI annotations
The ARG is also available in RUN commands for custom build logic:
RUN go build -ldflags "-X main.BuildTime=$SOURCE_DATE_EPOCH" -o app
Co-authored-by: Ona <no-reply@ona.com>1 parent 5d71f0e commit d153ac3
2 files changed
+32
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
336 | 365 | | |
337 | 366 | | |
338 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1992 | 1992 | | |
1993 | 1993 | | |
1994 | 1994 | | |
| 1995 | + | |
| 1996 | + | |
1995 | 1997 | | |
1996 | 1998 | | |
1997 | 1999 | | |
| |||
0 commit comments