https://github.com/reproducible-containers/buildkit-nix
Nix derivations as Dockerfiles (`docker build -f default.nix .`)
https://github.com/reproducible-containers/buildkit-nix
buildkit dockerfile nix
Last synced: 5 months ago
JSON representation
Nix derivations as Dockerfiles (`docker build -f default.nix .`)
- Host: GitHub
- URL: https://github.com/reproducible-containers/buildkit-nix
- Owner: reproducible-containers
- License: apache-2.0
- Created: 2021-12-03T12:53:28.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-13T10:51:18.000Z (almost 2 years ago)
- Last Synced: 2025-01-31T12:51:22.895Z (5 months ago)
- Topics: buildkit, dockerfile, nix
- Language: Go
- Homepage: https://github.com/moby/buildkit/issues/1650
- Size: 178 KB
- Stars: 171
- Watchers: 11
- Forks: 17
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BuildKit-Nix: Nix as Dockerfiles (`docker build -f default.nix .`)
BuildKit-Nix allows using Nix derivations (`default.nix`, `flake.nix`) as Dockerfiles.
## Examples
Legacy (with Niv):
- [`./examples/nginx/default.nix`](./examples/nginx/default.nix): NginxFlakes:
- [`./examples/nginx-flake/flake.nix`](./examples/nginx-flake/flake.nix): Nginx
- [`./examples/golang-httpserver-flake/flake.nix`](./examples/golang-httpserver-flake/flake.nix): A simple http server in Go
- [`./examples/rust-httpserver-flake/flake.nix`](./examples/rust-httpserver-flake/flake.nix): A simple http server in Rust## Usage
### With DockerRequires 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).### With nerdctl
```
cd examples/nginx
nerdctl build -t nginx-nix -f default.nix .
```### With buildctl
```
cd examples/nginx
buildctl build --frontend dockerfile.v0 --local dockerfile=. --local context=. --opt filename=default.nix
```