Nix derivations as Dockerfiles (`docker build -f default.nix .`)

Overview

BuildKit-Nix: Nix as Dockerfiles (docker build -f default.nix .)

BuildKit-Nix allows using Nix derivations (default.nix) as Dockerfiles.

Examples

Usage

With Docker

Requires 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
You might also like...
The example shows how to build a simple multi-tier web application using Kubernetes and Docker
The example shows how to build a simple multi-tier web application using Kubernetes and Docker

Guestbook Example This example shows how to build a simple multi-tier web application using Kubernetes and Docker. The application consists of a web f

A simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app to Docker Hub

go-pipeline-demo A repository containing a simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app t

Build and run Docker containers leveraging NVIDIA GPUs
Build and run Docker containers leveraging NVIDIA GPUs

NVIDIA Container Toolkit Introduction The NVIDIA Container Toolkit allows users to build and run GPU accelerated Docker containers. The toolkit includ

Woodpecker CI plugin to build multiarch Docker images with buildx

plugin-docker-buildx Woodpecker CI plugin to build multiarch Docker images with buildx Woodpecker CI plugin to build multiarch Docker images with buil

Copy files and artifacts via SSH using a binary, docker or Drone CI.

drone-scp Copy files and artifacts via SSH using a binary, docker or Drone CI. Feature Support routines. Support wildcard pattern on source list. Supp

Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.
Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.

Vilicus Table of Contents Overview How does it work? Architecture Development Run deployment manually Usage Example of analysis Overview Vilicus is an

Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments.
Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments.

Reward Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments. It makes possible to run multiple local envir

Fast docker image distribution plugin for containerd, based on CRFS/stargz
Fast docker image distribution plugin for containerd, based on CRFS/stargz

[ ⬇️ Download] [ 📔 Browse images] [ ☸ Quick Start (Kubernetes)] [ 🤓 Quick Start (nerdctl)] Stargz Snapshotter Read also introductory blog: Startup C

Docker LNMP (Nginx, PHP7/PHP5, MySQL, Redis)

DNMP(Docker + Nginx + MySQL + PHP7/5 + Redis)是一款全功能的LNMP一键安装程序。 使用前最好提前阅读一遍目录,以便快速上手,遇到问题也能及时排除。

Comments
  • Segmentation fault (core dumped) if used buildctl

    Segmentation fault (core dumped) if used buildctl

    Compiling the rust-httpserver-flake example process fails with an error

    Log:

    => ERROR /self/buildkit-nix helper --filename=flake.nix                                                                                                                                                                                                                                     11.8s
    ------
     > /self/buildkit-nix helper --filename=flake.nix:
    #0 2.900 time="2022-04-14T19:46:15Z" level=info msg="Populating cache from /cache into /nix"
    #0 11.68 time="2022-04-14T19:46:24Z" level=fatal msg="failed to run [cp -afT /cache /nix]: signal: segmentation fault (core dumped) (out=\"\")"
    ------
    flake.nix:1
    --------------------
       1 | >>> # syntax = ghcr.io/akihirosuda/buildkit-nix:[email protected]:ad13161464806242fd69dbf520bd70a15211b557d37f61178a4bf8e1fd39f1f2
       2 |
       3 |     {
    --------------------
    error: failed to solve: executor failed running [/self/buildkit-nix helper --filename=flake.nix]: exit code: 1
    

    Screenshot: image

    buildctl version

    buildctl github.com/moby/buildkit 0.10.0 068cf686a7e5c3254244d0acc54636f4f393611e

    builskit server version:

    buildkit:v0.8.2-rootless

    Run command:

    buildctl --addr tcp://127.0.0.1:1234 --tlsdir ./buildkit  build --frontend dockerfile.v0 --local context=. --local dockerfile=. --opt filename=flake.nix --output "type=image,name=$IMAGE_NAME:$IMAGE_DEV_TAG,push=false"
    
    bug 
    opened by BogdanovAleksei 6
  • Add support for .dockerignore (or similar mechanism)

    Add support for .dockerignore (or similar mechanism)

    I started to look into adding support for .dockerignore files when creating the build context, but I'm afraid I have no idea what I am doing. Seems like you can pull most of what you need from the standard Buildkit builder

    Right now copying the build context takes quite a while due to my repository with a multi-gigabyte Git history

    enhancement 
    opened by tristanpemble 1
Releases(v0.0.2)
  • v0.0.2(Dec 28, 2021)

    • Update Nix to 2.5.1 (#3 )
    • Support Flake (#4)
      • Thanks to @tomberek for providing hints (#1).

    Image: https://github.com/AkihiroSuda/buildkit-nix/pkgs/container/buildkit-nix/12421706?tag=v0.0.2

    Source code(tar.gz)
    Source code(zip)
Owner
Akihiro Suda
A maintainer of Moby(dockerd), BuildKit, containerd, and runc.
Akihiro Suda
Installs containerd on Windows, optionally with default CNI plugins

containerd-installer Installs containerd on Windows, optionally with default CNI plugins Usage NAME: containerd-installer.exe - Install containerd

Markus Lippert 12 Sep 19, 2022
Explore Docker registries and manipulate Docker images!

L/S tags Utility and API to manipulate (analyze, synchronize and aggregate) images across different Docker registries. Example invocation $ lstags alp

Ivan Ilves 293 Sep 12, 2022
Docker-based remote code runner / 基于 Docker 的远程代码运行器

Docker-based remote code runner / 基于 Docker 的远程代码运行器

E99p1ant 36 Sep 13, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

null 107 Aug 31, 2022
Hassle-free minimal CI/CD for git repositories with docker or docker-compose projects.

GIT-PIPE Hassle-free minimal CI/CD for git repos for docker-based projects. Features: zero configuration for repos by default automatic encrypted back

Aleksandr Baryshnikov 50 Sep 23, 2022
Tool to convert docker-compose files to set of simple docker commands

docker-decompose Tool to convert docker-compose files to set of simple docker commands. Install Use go get to install the latest version of the librar

Liri S 2 Apr 12, 2022
Go-http-server-docker - Simple sample server using docker and go

go-http-server-docker Simple sample webserver using docker and go.

null 0 Jan 8, 2022
Docker-hub-rate-limit - Show pulling rate status of Docker-hub

Docker-Hub Pull Rate Status This tool shows current status of docker hub pull ra

Tak 1 Jan 28, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Daniel Dias de Assumpção 12 Sep 6, 2022
Dotnet-appsettings-env - Convert .NET appsettings.json file to Kubernetes, Docker and Docker-Compose environment variables

dotnet-appsettings-env Convert .NET appsettings.json file to Kubernetes, Docker

Daniel Dias de Assumpção 1 Feb 16, 2022