docker load arion-base-image

This commit is contained in:
Robert Hensing 2019-09-29 23:45:52 +02:00
parent 02d319acf6
commit c88d2bb9cf
4 changed files with 46 additions and 10 deletions

View File

@ -9,7 +9,7 @@
"PATH": "/usr/bin:/run/current-system/sw/bin/",
"container": "docker"
},
"image": "webserver:<HASH>",
"image": "arion-base:<HASH>",
"ports": [
"8000:80"
],
@ -33,7 +33,7 @@
"images": [
{
"image": "<STOREPATH>",
"imageName": "webserver",
"imageName": "arion-base",
"imageTag": "<HASH>"
}
],

View File

@ -22,6 +22,7 @@ let
./modules/composition/host-environment.nix
./modules/composition/images.nix
./modules/composition/service-info.nix
./modules/composition/arion-base-image.nix
];
argsModule = {

View File

@ -0,0 +1,41 @@
# This module is subject to change.
# In particular, arion-base should use a generic non-service image building system
{ config, lib, pkgs, ... }:
let
tag = lib.head (lib.strings.splitString "-" (baseNameOf builtImage.outPath));
name = "arion-base";
builtImage = pkgs.dockerTools.buildLayeredImage {
inherit name;
contents = pkgs.runCommand "minimal-contents" {} ''
mkdir -p $out/bin $out/usr/bin
ln -s /run/system/bin/sh $out/bin/sh
ln -s /run/system/usr/bin/env $out/usr/bin/env
'';
config = {};
};
in
{
options = {
arionBaseImage = lib.mkOption {
type = lib.types.str;
description = "Image to use when using useHostStore. Don't use this option yourself. It's going away.";
internal = true;
};
};
config = {
arionBaseImage = "${name}:${tag}";
build.imagesToLoad = lib.mkIf (lib.any (s: s.config.service.useHostStore) (lib.attrValues config.docker-compose.evaluatedServices)) [
{ image = builtImage; imageName = name; imageTag = tag; }
];
};
}

View File

@ -29,14 +29,8 @@ in
};
};
config = mkIf config.service.useHostStore {
image.nixBuild = true;
image.contents = [
(pkgs.runCommand "minimal-contents" {} ''
mkdir -p $out/bin $out/usr/bin
ln -s /run/system/bin/sh $out/bin/sh
ln -s /run/system/usr/bin/env $out/usr/bin/env
'')
];
image.nixBuild = false; # no need to build and load
service.image = config.composition.arionBaseImage;
service.environment.NIX_REMOTE = lib.optionalString config.service.useHostNixDaemon "daemon";
service.volumes = [
"${config.host.nixStorePrefix}/nix/store:/nix/store${lib.optionalString config.service.hostStoreAsReadOnly ":ro"}"