48 lines
1.1 KiB
Nix
48 lines
1.1 KiB
Nix
{ pkgs, ... }:
|
|
let
|
|
postgresql = pkgs.postgresql.overrideAttrs (oldAttrs: {
|
|
patches = oldAttrs.patches or [ ] ++ [ ./allow-root.patch ];
|
|
});
|
|
|
|
entrypoint = pkgs.writeTextFile {
|
|
name = "entrypoint";
|
|
executable = true;
|
|
destination = "/bin/entrypoint";
|
|
text = builtins.readFile ./entrypoint.sh;
|
|
};
|
|
in
|
|
pkgs.dockerTools.buildImage {
|
|
name = "postgresql";
|
|
fromImage = pkgs.docker-image-base;
|
|
|
|
copyToRoot = pkgs.buildEnv {
|
|
name = "root";
|
|
paths = [
|
|
entrypoint
|
|
postgresql
|
|
];
|
|
pathsToLink = [
|
|
"/bin"
|
|
"/lib"
|
|
"/share"
|
|
];
|
|
};
|
|
|
|
runAsRoot = ''
|
|
mkdir -p /etc/postgresql /run/postgresql
|
|
cp ${postgresql}/share/postgresql/postgresql.conf.sample /etc/postgresql/postgresql.conf
|
|
${pkgs.gnused}/bin/sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /etc/postgresql/postgresql.conf
|
|
'';
|
|
|
|
config = {
|
|
Entrypoint = [ "entrypoint" ];
|
|
ExposedPorts = {
|
|
"5432/tcp" = { };
|
|
};
|
|
WorkingDir = "/var/lib/postgresql";
|
|
Volumes = {
|
|
"/var/lib/postgresql/data" = { };
|
|
};
|
|
};
|
|
}
|