about summary refs log tree commit diff
path: root/pkgs/build-support/docker/examples.nix
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-05-18 21:09:48 +0200
committerJan Tojnar <jtojnar@gmail.com>2020-05-18 21:09:48 +0200
commitf8a9c6efac0199d72884e82117636b5896b7e202 (patch)
treedb5a22587988bce5c645768fc9b40556f5708493 /pkgs/build-support/docker/examples.nix
parent682b7c2a1936c4d4298ce10629f2bd99d2fb54fb (diff)
parent7f40cfd97b4df5bcb039c0efb0710abf47b849b8 (diff)
downloadnixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar.gz
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar.bz2
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar.lz
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar.xz
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.tar.zst
nixlib-f8a9c6efac0199d72884e82117636b5896b7e202.zip
Merge branch 'staging-next' into staging
Diffstat (limited to 'pkgs/build-support/docker/examples.nix')
-rw-r--r--pkgs/build-support/docker/examples.nix41
1 files changed, 37 insertions, 4 deletions
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index f42b35e64943..d533e3abd03b 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -69,6 +69,12 @@ rec {
     tag = "latest";
     contents = pkgs.nginx;
 
+    extraCommands = ''
+      # nginx still tries to read this directory even if error_log
+      # directive is specifying another file :/
+      mkdir -p var/log/nginx
+      mkdir -p var/cache/nginx
+    '';
     runAsRoot = ''
       #!${pkgs.stdenv.shell}
       ${shadowSetup}
@@ -231,14 +237,41 @@ rec {
     '';
   };
 
-  # 14. Create another layered image, for comparing layers with image 10.
+  # 14. Environment variable inheritance.
+  # Child image should inherit parents environment variables,
+  # optionally overriding them.
+  environmentVariables = let
+    parent = pkgs.dockerTools.buildImage {
+      name = "parent";
+      tag = "latest";
+      config = {
+        Env = [
+          "FROM_PARENT=true"
+          "LAST_LAYER=parent"
+        ];
+      };
+    };
+  in pkgs.dockerTools.buildImage {
+    name = "child";
+    fromImage = parent;
+    tag = "latest";
+    contents = [ pkgs.coreutils ];
+    config = {
+      Env = [
+        "FROM_CHILD=true"
+        "LAST_LAYER=child"
+      ];
+    };
+  };
+
+  # 15. Create another layered image, for comparing layers with image 10.
   another-layered-image = pkgs.dockerTools.buildLayeredImage {
     name = "another-layered-image";
     tag = "latest";
     config.Cmd = [ "${pkgs.hello}/bin/hello" ];
   };
 
-  # 15. Create a layered image with only 2 layers
+  # 16. Create a layered image with only 2 layers
   two-layered-image = pkgs.dockerTools.buildLayeredImage {
     name = "two-layered-image";
     tag = "latest";
@@ -247,7 +280,7 @@ rec {
     maxLayers = 2;
   };
 
-  # 16. Create a layered image with more packages than max layers.
+  # 17. Create a layered image with more packages than max layers.
   # coreutils and hello are part of the same layer
   bulk-layer = pkgs.dockerTools.buildLayeredImage {
     name = "bulk-layer";
@@ -258,7 +291,7 @@ rec {
     maxLayers = 2;
   };
 
-  # 17. Create a "layered" image without nix store layers. This is not
+  # 18. Create a "layered" image without nix store layers. This is not
   # recommended, but can be useful for base images in rare cases.
   no-store-paths = pkgs.dockerTools.buildLayeredImage {
     name = "no-store-paths";