Nix derivations as Dockerfiles (`docker build -f default.nix .`)
189
stars
33
commits
Go
primary language
Sep 13, 2023
updated
docker build -f default.nix .)BuildKit-Nix allows using Nix derivations (default.nix, flake.nix) as Dockerfiles.
Legacy (with Niv):
./examples/nginx/default.nix: NginxFlakes:
./examples/nginx-flake/flake.nix: Nginx./examples/golang-httpserver-flake/flake.nix: A simple http server in Go./examples/rust-httpserver-flake/flake.nix: A simple http server in RustRequires Docker 20.10 or later.
cd examples/nginx
export DOCKER_BUILDKIT=1
docker build -t nginx-nix -f default.nix .
docker run -d -p 8080:80 --name nginx-nix nginx-nix
The digest of the contents of the image is reproducible:
docker exec nginx-nix cat /.buildkit-nix/result.gunzipped.digest
Note: While the digest of the contents of the image is reproducible (as long as Nix can reproduce it), the digest of the image itself might not be always reproducible, due to potential non-determinism of gzip (and possibly other misc stuffs inside BuildKit).
cd examples/nginx
nerdctl build -t nginx-nix -f default.nix .
cd examples/nginx
buildctl build --frontend dockerfile.v0 --local dockerfile=. --local context=. --opt filename=default.nix
32 commits
1 commits
Go
87.4%
Shell
7.8%
Dockerfile
4.8%
Nix derivations as Dockerfiles (`docker build -f default.nix .`)
189
stars
33
commits
Go
primary language
Sep 13, 2023
updated
docker build -f default.nix .)BuildKit-Nix allows using Nix derivations (default.nix, flake.nix) as Dockerfiles.
Legacy (with Niv):
./examples/nginx/default.nix: NginxFlakes:
./examples/nginx-flake/flake.nix: Nginx./examples/golang-httpserver-flake/flake.nix: A simple http server in Go./examples/rust-httpserver-flake/flake.nix: A simple http server in RustRequires Docker 20.10 or later.
cd examples/nginx
export DOCKER_BUILDKIT=1
docker build -t nginx-nix -f default.nix .
docker run -d -p 8080:80 --name nginx-nix nginx-nix
The digest of the contents of the image is reproducible:
docker exec nginx-nix cat /.buildkit-nix/result.gunzipped.digest
Note: While the digest of the contents of the image is reproducible (as long as Nix can reproduce it), the digest of the image itself might not be always reproducible, due to potential non-determinism of gzip (and possibly other misc stuffs inside BuildKit).
cd examples/nginx
nerdctl build -t nginx-nix -f default.nix .
cd examples/nginx
buildctl build --frontend dockerfile.v0 --local dockerfile=. --local context=. --opt filename=default.nix
32 commits
1 commits
Go
87.4%
Shell
7.8%
Dockerfile
4.8%