2018-02-14 05:20:16 +00:00
|
|
|
# this test creates a simple GNU image with docker tools and sees if it executes
|
|
|
|
|
|
|
|
import ./make-test.nix ({ pkgs, ... }: {
|
|
|
|
name = "docker-tools";
|
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2018-04-14 11:41:23 +00:00
|
|
|
maintainers = [ lnl7 ];
|
2018-02-14 05:20:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
docker =
|
|
|
|
{ config, pkgs, ... }: {
|
2018-02-16 17:24:48 +00:00
|
|
|
virtualisation = {
|
2018-03-04 16:48:07 +00:00
|
|
|
diskSize = 2048;
|
2018-02-16 17:24:48 +00:00
|
|
|
docker.enable = true;
|
|
|
|
};
|
2018-02-14 05:20:16 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript =
|
2018-02-16 17:24:48 +00:00
|
|
|
''
|
|
|
|
$docker->waitForUnit("sockets.target");
|
2018-02-14 05:20:16 +00:00
|
|
|
|
2018-02-16 17:24:48 +00:00
|
|
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
|
2018-04-14 11:41:23 +00:00
|
|
|
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.bash.imageName} bash --version");
|
2018-03-04 16:48:07 +00:00
|
|
|
$docker->succeed("docker rmi ${pkgs.dockerTools.examples.bash.imageName}");
|
2018-02-14 05:20:16 +00:00
|
|
|
|
2018-03-04 16:48:07 +00:00
|
|
|
# Check if the nix store is correctly initialized by listing dependencies of the installed Nix binary
|
2018-02-16 17:24:48 +00:00
|
|
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nix}'");
|
2018-04-14 11:41:23 +00:00
|
|
|
$docker->succeed("docker run --rm ${pkgs.dockerTools.examples.nix.imageName} nix-store -qR ${pkgs.nix}");
|
2018-03-04 16:48:07 +00:00
|
|
|
$docker->succeed("docker rmi ${pkgs.dockerTools.examples.nix.imageName}");
|
2018-02-14 05:20:16 +00:00
|
|
|
|
2018-02-16 17:24:48 +00:00
|
|
|
# To test the pullImage tool
|
|
|
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nixFromDockerHub}'");
|
2018-03-04 16:48:07 +00:00
|
|
|
$docker->succeed("docker run --rm nixos/nix:1.11 nix-store --version");
|
|
|
|
$docker->succeed("docker rmi nixos/nix:1.11");
|
2018-02-14 05:20:16 +00:00
|
|
|
|
2018-02-16 17:24:48 +00:00
|
|
|
# To test runAsRoot and entry point
|
|
|
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.nginx}'");
|
|
|
|
$docker->succeed("docker run --name nginx -d -p 8000:80 ${pkgs.dockerTools.examples.nginx.imageName}");
|
|
|
|
$docker->waitUntilSucceeds('curl http://localhost:8000/');
|
|
|
|
$docker->succeed("docker rm --force nginx");
|
2018-03-04 16:48:07 +00:00
|
|
|
$docker->succeed("docker rmi '${pkgs.dockerTools.examples.nginx.imageName}'");
|
|
|
|
|
|
|
|
# An pulled image can be used as base image
|
|
|
|
$docker->succeed("docker load --input='${pkgs.dockerTools.examples.onTopOfPulledImage}'");
|
|
|
|
$docker->succeed("docker run --rm ontopofpulledimage hello");
|
|
|
|
$docker->succeed("docker rmi ontopofpulledimage");
|
2018-02-16 17:24:48 +00:00
|
|
|
'';
|
2018-02-14 05:20:16 +00:00
|
|
|
})
|