kubenix/tests/images.nix

60 lines
1.3 KiB
Nix
Raw Normal View History

2019-02-25 17:16:24 +01:00
{
2022-04-02 12:40:35 -07:00
pkgs,
dockerTools,
lib,
...
}:
with lib; {
2020-04-05 21:25:34 +07:00
curl = dockerTools.buildLayeredImage {
name = "curl";
tag = "latest";
2022-04-02 12:40:35 -07:00
config.Cmd = ["${pkgs.bash}" "-c" "sleep infinity"];
contents = [pkgs.bash pkgs.curl pkgs.cacert];
2020-04-05 21:25:34 +07:00
};
2022-04-02 12:40:35 -07:00
nginx = let
nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nginx nginx;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
access_log /dev/stdout;
server {
listen ${nginxPort};
index index.html;
location / {
root ${nginxWebRoot};
2019-02-25 17:16:24 +01:00
}
}
2022-04-02 12:40:35 -07:00
}
'';
nginxWebRoot = pkgs.writeTextDir "index.html" ''
<html><body><h1>Hello from NGINX</h1></body></html>
'';
in
2021-05-13 17:27:08 -04:00
dockerTools.buildLayeredImage {
name = "xtruder/nginx";
tag = "latest";
2022-04-02 12:40:35 -07:00
contents = [pkgs.nginx];
2021-05-13 17:27:08 -04:00
extraCommands = ''
mkdir -p etc
chmod u+w etc
mkdir -p var/cache/nginx
chmod u+w var/cache/nginx
mkdir -p var/log/nginx
chmod u+w var/log/nginx
echo "nginx:x:1000:1000::/:" > etc/passwd
echo "nginx:x:1000:nginx" > etc/group
'';
config = {
2022-04-02 12:40:35 -07:00
Cmd = ["nginx" "-c" nginxConf];
2021-05-13 17:27:08 -04:00
ExposedPorts = {
2022-04-02 12:40:35 -07:00
"${nginxPort}/tcp" = {};
2021-05-13 17:27:08 -04:00
};
2019-02-25 17:16:24 +01:00
};
};
}