Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use COPY --link to share Go layer across OS variants / updates #505

Merged
merged 1 commit into from
Jan 20, 2024

Conversation

tianon
Copy link
Member

@tianon tianon commented Jan 16, 2024

This makes the Go layer reproducible such that re-pulling it can be avoided when switching between OS variants or OS updates.

$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/alpine3.18 --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/alpine3.19 --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/bookworm --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/bullseye --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5

touch -t "$date" /usr/local/.go-date-stamp; \
find /usr/local/go -depth -newer /usr/local/.go-date-stamp -exec touch -ht "$date" '{}' +; \
rm /usr/local/.go-date-stamp; \
touch -t "$date" /usr/local; \
Copy link
Member

@LaurentGoderre LaurentGoderre Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be a shared jq template or is it too early for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too early for that IMO 😅

Dockerfile-linux.template Outdated Show resolved Hide resolved
This makes the Go layer reproducible such that re-pulling it can be avoided when switching between OS variants or OS updates.

```console
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/alpine3.18 --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/alpine3.19 --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/bookworm --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
$ docker buildx build --builder foo --pull --build-arg BUILDKIT_SYNTAX=docker/dockerfile:1 1.21/bullseye --quiet --output type=oci | tar -tv | grep a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
-r--r--r-- 0/0        67061931 1969-12-31 16:00 blobs/sha256/a3881458cc9d5f6798ed03914b3fb322f3620ca53deca3b2c4460676912d16f5
```
@yosifkit yosifkit merged commit 26b9447 into docker-library:master Jan 20, 2024
36 checks passed
@yosifkit yosifkit deleted the link-test branch January 20, 2024 00:54
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jan 20, 2024
Changes:

- docker-library/golang@26b9447: Merge pull request docker-library/golang#505 from infosiftr/link-test
- docker-library/golang@a6fd6ec: Use `COPY --link` to share Go layer across OS variants / updates
- docker-library/golang@09d6a0c: Adjust versions.json field ordering to be more human-friendly
martin-g pushed a commit to martin-g/docker-official-images that referenced this pull request Apr 3, 2024
Changes:

- docker-library/golang@26b9447: Merge pull request docker-library/golang#505 from infosiftr/link-test
- docker-library/golang@a6fd6ec: Use `COPY --link` to share Go layer across OS variants / updates
- docker-library/golang@09d6a0c: Adjust versions.json field ordering to be more human-friendly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants