reproducible-containers / buildkit-nix

Nix derivations as Dockerfiles (`docker build -f default.nix .`)
https://github.com/moby/buildkit/issues/1650
Apache License 2.0
168 stars 17 forks source link

Build complaining about /homeless-shelter #23

Open mikroskeem opened 8 months ago

mikroskeem commented 8 months ago
[+] Building 362.2s (11/11) FINISHED                                                                                                                                                       docker:colima
 => [internal] load .dockerignore                                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                                     0.0s
 => [internal] load build definition from flake.nix                                                                                                                                                 0.0s
 => => transferring dockerfile: 3.58kB                                                                                                                                                              0.0s
 => resolve image config for ghcr.io/reproducible-containers/buildkit-nix:v0.1.1@sha256:7d4c42a5c6baea2b21145589afa85e0862625e6779c89488987266b85e088021                                            0.0s
 => CACHED docker-image://ghcr.io/reproducible-containers/buildkit-nix:v0.1.1@sha256:7d4c42a5c6baea2b21145589afa85e0862625e6779c89488987266b85e088021                                               0.0s
 => [internal] local dockerfile                                                                                                                                                                     0.1s
 => => transferring dockerfile: 866.43kB                                                                                                                                                            0.1s
 => resolve image config for ghcr.io/reproducible-containers/buildkit-nix:v0.1.1@sha256:7d4c42a5c6baea2b21145589afa85e0862625e6779c89488987266b85e088021                                            0.0s
 => [internal] self image                                                                                                                                                                           0.0s
 => resolve image config for docker.io/nixos/nix:2.17.0@sha256:a186d0501304e87751280b7b6ad62b54b9d08b8c5c63b9752eac408e1159c340                                                                     0.0s
 => [internal] local context                                                                                                                                                                        0.1s
 => => transferring context: 866.43kB                                                                                                                                                               0.1s
 => CACHED [internal] nix image                                                                                                                                                                     0.0s
 => ERROR /self/buildkit-nix helper --filename=flake.nix                                                                                                                                          352.3s
------
 > /self/buildkit-nix helper --filename=flake.nix:
0.232 time="2024-03-11T08:15:02Z" level=info msg="Populating cache from /cache into /nix"
0.237 time="2024-03-11T08:15:02Z" level=info msg="Running [nix --extra-experimental-features nix-command --extra-experimental-features flakes build --option build-users-group  /dockerfile] (flake mode: true)"
0.286 warning: Git tree '/dockerfile' is dirty
1.229 copying path '/nix/store/8rrzq23h2zq7sv5l2vhw44kls5w0f654-source' from 'https://cache.nixos.org'...
18.66 these 56 derivations will be built:
<snip>
352.1 error: home directory '/homeless-shelter' exists; please remove it to assure purity of builds without sandboxing
352.2 time="2024-03-11T08:20:54Z" level=fatal msg="exit status 1"
------
flake.nix:1
--------------------
   1 | >>> # syntax = ghcr.io/reproducible-containers/buildkit-nix:v0.1.1@sha256:7d4c42a5c6baea2b21145589afa85e0862625e6779c89488987266b85e088021
   2 |
   3 |     {
--------------------
ERROR: failed to solve: process "/self/buildkit-nix helper --filename=flake.nix" did not complete successfully: exit code: 1

docker system info:

Client:
 Version:    24.0.5
 Context:    colima
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.0
    Path:     /nix/store/bx6fxfbfjh99rqxwwr1g92ahpz4fgz3x-docker-plugins/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.23.1
    Path:     /nix/store/bx6fxfbfjh99rqxwwr1g92ahpz4fgz3x-docker-plugins/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 20
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-21-generic
 Operating System: Ubuntu 23.10
 OSType: linux
 Architecture: aarch64
 CPUs: 2
 Total Memory: 5.772GiB
 Name: colima
 ID: <snip>
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
jcaesar commented 1 week ago

I can reproduce this when trying out examples/rust-httpserver-flake, by running nix flake update nixpkgs --override-flake nixpkgs github:NixOS/nixpkgs/3ce0ea52a0a71ac04f4ce0a2c8a629e02a4e6279, and then docker build -f flake.nix ..

Where did you encounter this? I think this might be a problem with buildRustPackage, not this repository. [Edit:] Mh, or maybe it is this repository. Just doing docker run --rm -ti nixos/nix:2.18.9 nix -vvL --extra-experimental-features 'nix-command flakes' build 'git+https://github.com/reproducible-containers/buildkit-nix/?dir=examples/rust-httpserver-flake&rev=00854fe101ddad3d9e97f571eea1eb7f07311268' --override-input nixpkgs github:NixOS/nixpkgs/3ce0ea52a0a71ac04f4ce0a2c8a629e02a4e6279 does not lead to this problem.

mikroskeem commented 1 week ago

Whether it is related to buildRustPackage or not (but you already mentioned in the edit it's working with upstream raw Nix image), this issue still implies that there is setup bug somewhere.