Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Update buildkit #46

Merged
merged 128 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
b81b56e
Remove duplicate "not found" from some error messages
thaJeztah Mar 29, 2021
3bdb6b5
git: support subdir component
tonistiigi May 20, 2021
dbbe65b
Update SSH agent socket handling to support Windows OpenSSH using nam…
sschaap May 20, 2021
146ea46
Update Windows named pipe handling for SSH forwarding to use x/sys/wi…
sschaap May 27, 2021
f3bdb4a
Rename SSH agent forwarding helper parsePlatformSocketPath() to getWi…
sschaap May 27, 2021
c9a5f88
Fix regular expression to test for Windows named pipe in SSH agent pa…
sschaap May 27, 2021
22dd74a
update to go 1.16
thaJeztah Jun 1, 2021
0c13337
Merge pull request #2127 from sschaap/feature/windows-openssh
tonistiigi Jun 5, 2021
89f23a8
go.mod: update docker and docker cli to v20.10.7
thaJeztah Jun 5, 2021
8e88c5d
Merge pull request #2149 from thaJeztah/update_docker
tonistiigi Jun 5, 2021
33af267
hack: update proto generators for arm64
tonistiigi Jun 7, 2021
19453d5
test: fix mirror cache handling
tonistiigi Jun 8, 2021
167e0dc
cache: fix possible nil dereferences
tonistiigi Jun 8, 2021
d458fb3
Merge pull request #2156 from tonistiigi/nil-deref-fix
AkihiroSuda Jun 8, 2021
817955d
Merge pull request #2116 from tonistiigi/git-subdir
AkihiroSuda Jun 8, 2021
04be2c3
Merge pull request #2154 from tonistiigi/arm64-proto
AkihiroSuda Jun 8, 2021
67953d6
Merge pull request #2155 from tonistiigi/mirror-fix
AkihiroSuda Jun 8, 2021
12c9920
move RegistryConfig to resolver package
thaJeztah Jun 5, 2021
884578f
Merge pull request #2151 from thaJeztah/move_config_opt
tonistiigi Jun 8, 2021
03af083
Merge pull request #2144 from thaJeztah/bump_golang
tonistiigi Jun 8, 2021
a53e054
vendor: fix broken gosum
tonistiigi Jun 8, 2021
7e4e676
Merge pull request #2160 from tonistiigi/fix-gosum
thaJeztah Jun 8, 2021
d44a406
add hack/shell helper for dev shell environment
tonistiigi Jun 8, 2021
53e7116
session: make sure all token request keep correct context
tonistiigi Jun 8, 2021
ce27b7e
filesync: ensure sendclose is always called
tonistiigi Jun 8, 2021
8993c69
Merge pull request #2159 from tonistiigi/hack-shell
AkihiroSuda Jun 9, 2021
1764b3b
Enable stargz snapshotter to use session for snapshot auth
ktock Oct 11, 2020
aed6932
Implement low-level parser primitives for heredocs
jedevc Jun 9, 2021
c362e15
Add support for parsing heredocs in ADD/COPY and RUN
jedevc Jun 9, 2021
de7fcce
Integrate heredoc support into ADD/COPY and RUN
jedevc Jun 9, 2021
2d35001
Add integration tests for dockerfile heredocs
jedevc Jun 9, 2021
0de03b4
Merge pull request #1733 from ktock/reghost
tonistiigi Jun 9, 2021
c98d24b
Update docker/docker to master / v21.xx-dev (post libnetwork integrat…
thaJeztah Jun 5, 2021
941e1b7
Fix doc about Stargz Snapshotter and registry authentication
ktock Jun 10, 2021
0f9f55f
Merge pull request #2165 from ktock/fixdoc
tonistiigi Jun 10, 2021
fa632c5
dockerfile: add documentation for here-docs
tonistiigi Jun 10, 2021
4518627
Merge pull request #2132 from jedevc/dockerfile-heredocs
tonistiigi Jun 10, 2021
b0c769b
Merge pull request #2150 from thaJeztah/update_docker_master
tonistiigi Jun 10, 2021
5648df8
Merge pull request #2162 from tonistiigi/filesync-sendclose
AkihiroSuda Jun 11, 2021
59d2f76
Merge pull request #2161 from tonistiigi/auth-context
AkihiroSuda Jun 11, 2021
baa4fcd
add differ support for local source
tonistiigi Apr 21, 2021
a7b155e
llb: don't allow content diff for now
tonistiigi Apr 21, 2021
e49dc64
Fix file modes with remote ADD commands
jedevc Jun 13, 2021
6a4a14b
Merge pull request #2171 from jedevc/remote-source-chmod
tonistiigi Jun 14, 2021
5429fe1
cache: avoid concurrent maps write on prune
tonistiigi Jun 15, 2021
976b7e9
metadata: hold lock on storageitem update
tonistiigi Jun 15, 2021
b9d5a8f
Merge pull request #2177 from tonistiigi/fix-prune-lock
tonistiigi Jun 15, 2021
9f254e1
Merge pull request #2178 from tonistiigi/metadata-lock
tonistiigi Jun 15, 2021
5f03335
Dockerfile: install fuse-overlayfs from apk
AkihiroSuda Jun 16, 2021
b97d0f7
vendor: update vt100 to fork and remove replace rule
tonistiigi Jun 15, 2021
2ccc0e2
Merge pull request #2180 from tonistiigi/vt100-unfork
AkihiroSuda Jun 16, 2021
292f1fa
add support for opentelemetry
tonistiigi Jun 2, 2021
8f50bae
replace opentracing with opentelemetry tracers
tonistiigi Jun 7, 2021
cfb73e5
hack: avoid updating generated proto version
tonistiigi Jun 7, 2021
9717e62
session: avoid tracing health checkpoint
tonistiigi Jun 7, 2021
c676959
disable otel error logging
tonistiigi Jun 13, 2021
b10f259
correctly validate span from context
tonistiigi Jun 15, 2021
0164c06
Merge pull request #2152 from tonistiigi/otel
AkihiroSuda Jun 16, 2021
111153e
dockerfile: ensure config resolve errors keep source location
tonistiigi Jun 17, 2021
b6b07d1
Merge pull request #2183 from tonistiigi/dockerfile-config-error
AkihiroSuda Jun 17, 2021
9e274c7
remove go fork for building windows/arm64
tonistiigi Jun 17, 2021
74807a1
Dockerfile: remove nsswitch as default in go1.16
tonistiigi Jun 17, 2021
7849ab5
retryhandler: use net.ErrClosed for error check
tonistiigi Jun 17, 2021
87c757f
Merge pull request #2187 from tonistiigi/unfork-win-arm64
AkihiroSuda Jun 18, 2021
1e623f9
Merge pull request #2188 from tonistiigi/go1.16-updates
AkihiroSuda Jun 18, 2021
c325f89
replace uses of deprecated containerd/sys.RunningInUserNS()
thaJeztah Jun 18, 2021
573f1b1
Merge pull request #2189 from thaJeztah/replace_deprecated_userns
tonistiigi Jun 18, 2021
c773a21
integration: add common context base to all integration tests
tonistiigi Jun 19, 2021
6409a07
Merge pull request #2191 from tonistiigi/integration-ctx
tonistiigi Jun 19, 2021
7489cc8
vendor: update opentelemetry to 1.0.0-rc
tonistiigi Jun 19, 2021
1c037fd
Merge pull request #2192 from tonistiigi/otel-update
AkihiroSuda Jun 20, 2021
69a8caa
add current tracing context detection and exec propagation
tonistiigi Jun 9, 2021
723ea57
add transform package to convert from otlp
tonistiigi Jun 9, 2021
b873f0b
tracing: add delegated exporter
tonistiigi Jun 10, 2021
750f9af
otlgrpc: provide a way to get otlp client from grpc conn
tonistiigi Jun 10, 2021
d8fc4e1
enable collecting traces via control api
tonistiigi Jun 9, 2021
d512920
support collecting traces from llb.Exec
tonistiigi Jun 14, 2021
14d606c
client: pass delegated exporter as parameter
tonistiigi Jun 21, 2021
9655dfe
update runc binary to v1.0.0 GA
AkihiroSuda Jun 11, 2021
1d0597e
handle unconfigured spans without errors
tonistiigi Jun 22, 2021
215e151
Merge pull request #2143 from AkihiroSuda/runc-v1.0.0
tonistiigi Jun 22, 2021
b4935eb
llb: add constraints to vertex and validate
tonistiigi Jun 23, 2021
e0124e1
llb: add constraints to async llb
tonistiigi Jun 23, 2021
4e0a573
Merge pull request #2179 from AkihiroSuda/apk-fuse-overlayfs
tonistiigi Jun 23, 2021
01b50a3
llb: ensure meta resolver uses platform form constraints
tonistiigi Jun 23, 2021
3eec428
flightcontrol: reduce contention between goroutines
tonistiigi Jun 22, 2021
799175f
Avoid nil pointer dereference when copying from image with no layers
aaronlehmann Jun 23, 2021
e70f855
Add test for copying from scratch
aaronlehmann Jun 23, 2021
8f2fd48
Check that scratch is mounted as empty dir
aaronlehmann Jun 23, 2021
103ad93
Merge pull request #2196 from tonistiigi/llb-resolve-constraints
AkihiroSuda Jun 24, 2021
c1a48b7
Make error message consistent when layer is empty
aaronlehmann Jun 26, 2021
a018bf5
Test with tonistiigi/test:nolayers as well
aaronlehmann Jun 27, 2021
6eab36d
Merge pull request #2197 from aaronlehmann/hash-empty
tonistiigi Jun 28, 2021
13c842b
ensure containerd io is complete and closed before returning
coryb Jun 28, 2021
63b1249
Merge pull request #2205 from coryb/flakey-tests
tonistiigi Jun 28, 2021
8d33bbd
Merge pull request #2195 from tonistiigi/flightcontrol-contention
tonistiigi Jun 28, 2021
1da8b67
[#2112] progress.Controller should own the progress.Writer to prevent…
coryb Jun 25, 2021
b1d441b
[#2112] progress.FromContext returns a writer factory
coryb Jun 28, 2021
f4fcba5
Merge pull request #2203 from coryb/issue-2112
coryb Jun 28, 2021
b9f8a58
contenthash: use SeekLowerBound to seek radix tree
tonistiigi Jun 15, 2021
dc86c52
dockerfile: fix git version detection
tonistiigi Jun 28, 2021
bb6f11c
Merge pull request #2208 from tonistiigi/dockerfile-version
AkihiroSuda Jun 29, 2021
5ad1ff3
Add support for heredocs with ONBUILD
jedevc Jun 29, 2021
ee39f5d
dockerfile: use none differ for dockerfile/dockerignore
tonistiigi Apr 21, 2021
921b0de
Merge pull request #2209 from jedevc/dockerfile-heredocs-onbuild
tonistiigi Jun 30, 2021
be8ab28
Merge pull request #2081 from tonistiigi/local-differ-none
AkihiroSuda Jul 1, 2021
600d283
progressui: print logs for failed step as summary in plain mode
tonistiigi Jul 1, 2021
460ba75
grpcerrors: avoid rpc error wrapping in error messages
tonistiigi Jul 1, 2021
a27d7c3
exec: improve error message on exec errors
tonistiigi Jul 1, 2021
8d70a9e
Merge pull request #2215 from tonistiigi/improve-errors
AkihiroSuda Jul 1, 2021
edc28d1
Merge pull request #2214 from tonistiigi/plain-error-logs
AkihiroSuda Jul 1, 2021
ec1bfc8
Improve heredoc parsing to allow more generic words
jedevc Jun 30, 2021
c99b558
Improve progress and history messages for heredoc-related commands
jedevc Jun 25, 2021
b85ef15
Remove unneeded Finalize method from ImmutableRef.
sipsma Jul 1, 2021
5840ec0
Merge pull request #2213 from jedevc/dockerfile-heredoc-parsing
tonistiigi Jul 1, 2021
521727e
Merge pull request #2201 from jedevc/dockerfile-heredocs-progress
tonistiigi Jul 1, 2021
7d38666
Merge pull request #2216 from sipsma/cleancache
tonistiigi Jul 1, 2021
f360472
Fix ref leak if fileop ref fails to mount.
sipsma Jul 1, 2021
3c4f737
Merge pull request #2217 from sipsma/fileop-ref-leak
sipsma Jul 2, 2021
f5c34a0
Merge pull request #2047 from thaJeztah/improve_errors
tonistiigi Jul 2, 2021
9cf28dc
Merge pull request #2182 from tonistiigi/seek-radix
AkihiroSuda Jul 2, 2021
1a7543a
Merge pull request #2163 from tonistiigi/detect-otel-env
AkihiroSuda Jul 2, 2021
05ac5df
enable riscv64 build
tonistiigi Jul 5, 2021
4f9ea01
Merge pull request #2222 from tonistiigi/riscv
tonistiigi Jul 6, 2021
9825801
Update QEMU emulators
crazy-max Jul 6, 2021
5fc0b3c
Merge pull request #2225 from crazy-max/binfmt-6.0.0
tonistiigi Jul 6, 2021
d199faa
Merge branch 'moby-master' into update-buildkit
alexcb Jul 6, 2021
bc866a4
fixes to work with buildkit master
alexcb Jul 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 14 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,34 @@ make images
Running tests:

```bash
make test
./hack/test integration gateway dockerfile
```

This runs all unit and integration tests in a containerized environment.
This runs all unit and integration tests, gateway client and dockerfile tests in a containerized environment.
Locally, every package can be tested separately with standard Go tools, but
integration tests are skipped if local user doesn't have enough permissions or
worker binaries are not installed.
worker binaries are not installed. The dockerfile tests run by first building new Dockerfile frontend
image and then loading it to the test environment. Builtin Dockerfile frontend can be tested with regular
integration tests.

```bash
# test a specific package only
make test TESTPKGS=./client
TESTPKGS=./client ./hack/test integration

# run a specific test with all worker combinations
make test TESTPKGS=./client TESTFLAGS="--run /TestCallDiskUsage -v"
TESTPKGS=./client TESTFLAGS="--run /TestCallDiskUsage -v" ./hack/test integration

# run all integration tests with a specific worker
# supported workers: oci, oci-rootless, containerd, containerd-1.1
make test TESTPKGS=./client TESTFLAGS="--run //worker=containerd -v"
TESTPKGS=./client TESTFLAGS="--run //worker=containerd -v" ./hack/test integration

# run a specific dockerfile test only on labs channel
DOCKERFILE_RELEASES=labs TESTFLAGS="--run /TestRunGlobalNetwork/worker=oci$/ -v" ./hack/test dockerfile
```

Set `TEST_KEEP_CACHE=1` for the test framework to keep external dependant images in a docker volume
if you are repeatedly calling `./hack/test` script. This helps to avoid rate limiting on the remote registry side.

Updating vendored dependencies:

```bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
REPO_SLUG_ORIGIN: "moby/buildkit:latest"
REPO_SLUG_TARGET: "moby/buildkit"
DF_REPO_SLUG_TARGET: "docker/dockerfile-upstream"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le"
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le,linux/riscv64"
CACHEKEY_INTEGRATION_TESTS: "integration-tests"
CACHEKEY_BINARIES: "binaries"
CACHEKEY_CROSS: "cross"
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.13
go-version: 1.16
-
name: Cache Go modules
uses: actions/cache@v2
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ run:
build-tags:
- dfrunsecurity
- dfrunnetwork
- dfheredoc

linters:
enable:
Expand Down
52 changes: 17 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1.2

ARG RUNC_VERSION=v1.0.0-rc95
ARG RUNC_VERSION=v1.0.0
ARG CONTAINERD_VERSION=v1.5.2
# containerd v1.4 for integration tests
ARG CONTAINERD_ALT_VERSION=v1.4.6
Expand All @@ -10,27 +10,25 @@ ARG REGISTRY_VERSION=2.7.1
ARG ROOTLESSKIT_VERSION=v0.14.2
ARG CNI_VERSION=v0.9.1
ARG SHADOW_VERSION=4.8.1
ARG FUSEOVERLAYFS_VERSION=v1.5.0
ARG STARGZ_SNAPSHOTTER_VERSION=v0.5.0

ARG ALPINE_VERSION=3.12
ARG ALPINE_VERSION=3.14

# git stage is used for checking out remote repository sources
FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS git
RUN apk add --no-cache git

# xx is a helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:810dc54d5144f133a218e88e319184bf8b9ce01d37d46ddb37573e90decd9eef AS xx
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:1e96844fadaa2f9aea021b2b05299bc02fe4c39a92d8e735b93e8e2b15610128 AS xx

FROM --platform=$BUILDPLATFORM golang:1.13-alpine AS gostable
FROM --platform=$BUILDPLATFORM golang:1.16-alpine AS golatest

FROM gostable AS go-linux
FROM golatest AS go-linux
FROM golatest AS go-darwin
FROM golatest AS go-windows-amd64
FROM golatest AS go-windows-386
FROM golatest AS go-windows-arm
FROM --platform=$BUILDPLATFORM tonistiigi/golang:497feff1-alpine AS go-windows-arm64
FROM --platform=$BUILDPLATFORM golang:1.17beta1-alpine AS go-windows-arm64
FROM go-windows-${TARGETARCH} AS go-windows

# gobuild is base stage for compiling go/cgo
Expand All @@ -51,7 +49,7 @@ WORKDIR $GOPATH/src/github.com/opencontainers/runc
ARG TARGETPLATFORM
# gcc is only installed for libgcc
# lld has issues building static binaries for ppc so prefer ld for it
RUN set -e; xx-apk add musl-dev gcc libseccomp-dev; \
RUN set -e; xx-apk add musl-dev gcc libseccomp-dev libseccomp-static; \
[ "$(xx-info arch)" != "ppc64le" ] || XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple
RUN --mount=from=runc-src,src=/usr/src/runc,target=. --mount=target=/root/.cache,type=cache \
CGO_ENABLED=1 xx-go build -mod=vendor -ldflags '-extldflags -static' -tags 'apparmor seccomp netgo cgo static_build osusergo' -o /usr/bin/runc ./ && \
Expand Down Expand Up @@ -91,8 +89,8 @@ RUN --mount=target=. --mount=target=/root/.cache,type=cache \

FROM scratch AS binaries-linux-helper
COPY --from=runc /usr/bin/runc /buildkit-runc
# built from https://github.com/tonistiigi/binfmt/runs/1743699129
COPY --from=tonistiigi/binfmt:buildkit@sha256:75583ce1cf4a7166fd2592f45e4ff3f53727eee6edcd3a3e804f749b1f214a39 / /
# built from https://github.com/tonistiigi/binfmt/releases/tag/buildkit%2Fv6.0.0-15
COPY --from=tonistiigi/binfmt:buildkit@sha256:81a03e6630e9c39df109bf24ae8c807881c4fd1703084827d855f8093cc7ab7a / /
FROM binaries-linux-helper AS binaries-linux
COPY --from=buildctl /usr/bin/buildctl /
COPY --from=buildkitd /usr/bin/buildkitd /
Expand All @@ -116,13 +114,10 @@ RUN --mount=from=binaries \
FROM scratch AS release
COPY --from=releaser /out/ /

FROM alpine:${ALPINE_VERSION} AS buildkit-export
# nsswitch.conf needs to be present to work around
# https://github.com/golang/go/issues/35305
# drop this once we start building with Go 1.16
# tonistiigi/alpine supports riscv64
FROM tonistiigi/alpine:${ALPINE_VERSION} AS buildkit-export
RUN apk add --no-cache fuse3 git openssh pigz xz \
&& ln -s fusermount3 /usr/bin/fusermount \
&& echo "hosts: files dns" >/etc/nsswitch.conf
&& ln -s fusermount3 /usr/bin/fusermount
COPY examples/buildctl-daemonless/buildctl-daemonless.sh /usr/bin/
VOLUME /var/lib/buildkit

Expand Down Expand Up @@ -151,6 +146,7 @@ RUN --mount=from=containerd-src,src=/usr/src/containerd,readwrite --mount=target
# containerd v1.4 for integration tests
FROM containerd-base as containerd-alt
ARG CONTAINERD_ALT_VERSION
ARG GO111MODULE=off
RUN --mount=from=containerd-src,src=/usr/src/containerd,readwrite --mount=target=/root/.cache,type=cache \
git fetch origin \
&& git checkout -q "$CONTAINERD_ALT_VERSION" \
Expand Down Expand Up @@ -183,16 +179,6 @@ RUN --mount=target=/root/.cache,type=cache \
xx-verify --static /out/containerd-stargz-grpc && \
xx-verify --static /out/ctr-remote

FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS fuse-overlayfs
RUN apk add --no-cache curl
COPY --from=xx / /
ARG FUSEOVERLAYFS_VERSION
ARG TARGETPLATFORM
RUN mkdir /out && \
curl -sSL -o /out/fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/${FUSEOVERLAYFS_VERSION}/fuse-overlayfs-$(xx-info march) && \
chmod +x /out/fuse-overlayfs && \
xx-verify --static /out/fuse-overlayfs

# Copy together all binaries needed for oci worker mode
FROM buildkit-export AS buildkit-buildkitd.oci_only
COPY --from=buildkitd.oci_only /usr/bin/buildkitd.oci_only /usr/bin/
Expand Down Expand Up @@ -264,9 +250,10 @@ ENV BUILDKIT_RUN_NETWORK_INTEGRATION_TESTS=1 BUILDKIT_CNI_INIT_LOCK_PATH=/run/bu
FROM integration-tests AS dev-env
VOLUME /var/lib/buildkit

# newuidmap & newgidmap binaries (shadow-uidmap 4.7-r1) shipped with alpine cannot be executed without CAP_SYS_ADMIN,
# newuidmap & newgidmap binaries (shadow-uidmap 4.8.1-r0) shipped with alpine cannot be executed without CAP_SYS_ADMIN,
# because the binaries are built without libcap-dev.
# So we need to build the binaries with libcap enabled.
# TODO: ask the Alpine upstream to enable libcap: https://github.com/moby/buildkit/issues/2038
FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS idmap
RUN apk add --no-cache git autoconf automake clang lld gettext-dev libtool make byacc binutils
COPY --from=xx / /
Expand All @@ -281,21 +268,16 @@ RUN CC=$(xx-clang --print-target-triple)-clang ./autogen.sh --disable-nls --disa
&& cp src/newuidmap src/newgidmap /usr/bin

# Rootless mode.
FROM alpine:${ALPINE_VERSION} AS rootless
RUN apk add --no-cache fuse3 git openssh pigz xz
FROM tonistiigi/alpine:${ALPINE_VERSION} AS rootless
RUN apk add --no-cache fuse3 fuse-overlayfs git openssh pigz xz
COPY --from=idmap /usr/bin/newuidmap /usr/bin/newuidmap
COPY --from=idmap /usr/bin/newgidmap /usr/bin/newgidmap
COPY --from=fuse-overlayfs /out/fuse-overlayfs /usr/bin/
# we could just set CAP_SETUID filecap rather than `chmod u+s`, but requires kernel >= 4.14
# nsswitch.conf needs to be present to work around
# https://github.com/golang/go/issues/35305
# drop this once we start building with Go 1.16
RUN chmod u+s /usr/bin/newuidmap /usr/bin/newgidmap \
&& adduser -D -u 1000 user \
&& mkdir -p /run/user/1000 /home/user/.local/tmp /home/user/.local/share/buildkit \
&& chown -R user /run/user/1000 /home/user \
&& echo user:100000:65536 | tee /etc/subuid | tee /etc/subgid \
&& echo "hosts: files dns" >/etc/nsswitch.conf
&& echo user:100000:65536 | tee /etc/subuid | tee /etc/subgid
COPY --from=rootlesskit /rootlesskit /usr/bin/
COPY --from=binaries / /usr/bin/
COPY examples/buildctl-daemonless/buildctl-daemonless.sh /usr/bin/
Expand Down
4 changes: 2 additions & 2 deletions cache/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (sr *immutableRef) computeBlobChain(ctx context.Context, createIfNeeded boo
return errors.Errorf("missing lease requirement for computeBlobChain")
}

if err := sr.Finalize(ctx, true); err != nil {
if err := sr.finalizeLocked(ctx); err != nil {
return err
}

Expand Down Expand Up @@ -174,7 +174,7 @@ func (sr *immutableRef) setBlob(ctx context.Context, desc ocispec.Descriptor) er
return nil
}

if err := sr.finalize(ctx, true); err != nil {
if err := sr.finalize(ctx); err != nil {
return err
}

Expand Down
21 changes: 15 additions & 6 deletions cache/contenthash/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ type cacheManager struct {
}

func (cm *cacheManager) Checksum(ctx context.Context, ref cache.ImmutableRef, p string, opts ChecksumOpts, s session.Group) (digest.Digest, error) {
if ref == nil {
if p == "/" {
return digest.FromBytes(nil), nil
}
return "", errors.Errorf("%s: no such file or directory", p)
}
cc, err := cm.GetCacheContext(ctx, ensureOriginMetadata(ref.Metadata()), ref.IdentityMapping())
if err != nil {
return "", nil
Expand Down Expand Up @@ -509,18 +515,19 @@ func (cc *cacheContext) includedPaths(ctx context.Context, m *mount, p string, o
root = txn.Root()
var (
updated bool
iter *iradix.Seeker
iter *iradix.Iterator
k []byte
kOk bool
)

iter = root.Iterator()

if opts.Wildcard {
iter = root.Seek([]byte{})
k, _, kOk = iter.Next()
} else {
k = convertPathToKey([]byte(p))
if _, kOk = root.Get(k); kOk {
iter = root.Seek(k)
iter.SeekLowerBound(append(append([]byte{}, k...), 0))
}
}

Expand Down Expand Up @@ -721,7 +728,7 @@ func (cc *cacheContext) checksum(ctx context.Context, root *iradix.Node, txn *ir
return nil, false, err
}
if cr == nil {
return nil, false, errors.Wrapf(errNotFound, "%q not found", convertKeyToPath(origk))
return nil, false, errors.Wrapf(errNotFound, "%q", convertKeyToPath(origk))
}
if cr.Digest != "" {
return cr, false, nil
Expand All @@ -732,7 +739,8 @@ func (cc *cacheContext) checksum(ctx context.Context, root *iradix.Node, txn *ir
case CacheRecordTypeDir:
h := sha256.New()
next := append(k, 0)
iter := root.Seek(next)
iter := root.Iterator()
iter.SeekLowerBound(append(append([]byte{}, next...), 0))
subk := next
ok := true
for {
Expand All @@ -750,7 +758,8 @@ func (cc *cacheContext) checksum(ctx context.Context, root *iradix.Node, txn *ir

if subcr.Type == CacheRecordTypeDir { // skip subfiles
next := append(subk, 0, 0xff)
iter = root.Seek(next)
iter = root.Iterator()
iter.SeekLowerBound(next)
}
subk, _, ok = iter.Next()
}
Expand Down
Loading