Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. { stdenv, symlinkJoin, dockerTools, coreutils, writeScript, glibcLocales,
  2. metadrift }:
  3.  
  4. let
  5.  
  6. metadriftConfig = {
  7. environment.systemPackages = [ metadrift ];
  8. };
  9.  
  10. minimalDocker =
  11. {
  12. imports = [ <nixpkgs/nixos/modules/profiles/minimal.nix> ];
  13. boot.isContainer = true;
  14. environment.etc.machine-id.text = "00000000000000000000000000000000";
  15. };
  16. eval =
  17. import <nixos/lib/eval-config.nix> {
  18. modules = [
  19. minimalDocker
  20. metadriftConfig
  21. ];
  22. };
  23. system =
  24. eval.config.system;
  25.  
  26. rootDir = "/data";
  27. homeDir = "${rootDir}/var/lib/metadrift";
  28. logDir = "/data/log";
  29.  
  30. port = 8743;
  31.  
  32. entrypoint = writeScript "entrypoint.sh" ''
  33. #!${stdenv.shell}
  34.  
  35. set -e
  36.  
  37. exec ${metadrift}/bin/metadrift-exe --port ${toString port}
  38. '';
  39.  
  40. in
  41. dockerTools.buildImage rec {
  42. name = "metadrift";
  43.  
  44. contents = symlinkJoin {
  45. name = "${name}-contents";
  46. paths = [
  47. system.build.etc
  48. system.path
  49. ];
  50. };
  51.  
  52. config = {
  53. Cmd = [ "${entrypoint}" ];
  54. Env = [ "PATH=${coreutils}/bin:$PATH"
  55. ''LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"''];
  56. ExposedPorts = {
  57. "${toString port}/tcp" = {};
  58. };
  59.  
  60. WorkingDir = "/data";
  61. Volumes = {
  62. "/data" = {};
  63. };
  64. };
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement