Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ericbmerritt/c1cc2aa29ac3f90a831ba8fffc77a52c to your computer and use it in GitHub Desktop.
Save ericbmerritt/c1cc2aa29ac3f90a831ba8fffc77a52c to your computer and use it in GitHub Desktop.
{ stdenv, symlinkJoin, dockerTools, coreutils, writeScript, glibcLocales,
metadrift }:
let
metadriftConfig = {
environment.systemPackages = [ metadrift ];
};
minimalDocker =
{
imports = [ <nixpkgs/nixos/modules/profiles/minimal.nix> ];
boot.isContainer = true;
environment.etc.machine-id.text = "00000000000000000000000000000000";
};
eval =
import <nixos/lib/eval-config.nix> {
modules = [
minimalDocker
metadriftConfig
];
};
system =
eval.config.system;
rootDir = "/data";
homeDir = "${rootDir}/var/lib/metadrift";
logDir = "/data/log";
port = 8743;
entrypoint = writeScript "entrypoint.sh" ''
#!${stdenv.shell}
set -e
exec ${metadrift}/bin/metadrift-exe --port ${toString port}
'';
in
dockerTools.buildImage rec {
name = "metadrift";
contents = symlinkJoin {
name = "${name}-contents";
paths = [
system.build.etc
system.path
];
};
config = {
Cmd = [ "${entrypoint}" ];
Env = [ "PATH=${coreutils}/bin:$PATH"
''LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"''];
ExposedPorts = {
"${toString port}/tcp" = {};
};
WorkingDir = "/data";
Volumes = {
"/data" = {};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment