spacepaste

  1.  
  2. { pkgs ? import (builtins.fetchTarball "https://d3g5gsiof5omrk.cloudfront.net/nixos/unstable-small/nixos-18.03pre115143.c7a152e5d0/nixexprs.tar.xz") {} }:
  3. with pkgs;
  4. let
  5. redis = pkgs.redis.overrideDerivation (attrs: rec {
  6. version = "4.0.1";
  7. name = "redis-${version}";
  8. src = fetchurl {
  9. url = "http://download.redis.io/releases/${name}.tar.gz";
  10. sha256 = "14bm8lkhylc93r4dgl7kkzzpw2xq7gr6w6h80n3jazqnx5mcsj90";
  11. };
  12. });
  13. in
  14. dockerTools.buildImage {
  15. name = "redis";
  16. tag = redis.version;
  17. runAsRoot = ''
  18. #!${stdenv.shell}
  19. ${dockerTools.shadowSetup}
  20. groupadd -r redis
  21. useradd -r -g redis -d /data -M redis
  22. mkdir /data
  23. chown redis:redis /data
  24. '';
  25. config = {
  26. Entrypoint = [
  27. "${su-exec}/bin/su-exec"
  28. "redis"
  29. "${redis}/bin/redis-server"
  30. # Docker-compose is in charge of mounting this config file
  31. "/data/redis.conf"
  32. ];
  33. # Exposed ports is unique per host
  34. # ExposedPorts = {
  35. # "6379/tcp" = {};
  36. # };
  37. WorkingDir = "/data";
  38. Volumes = {
  39. "/data" = {};
  40. };
  41. };
  42. }
  43.