L-Nafaryus
a4d8f5232e
Some checks failed
nix / check (push) Failing after 1m15s
flake: fix name conventions flake: configurations -> lib.preconfiguredModules flake.packages: rework platform dependency with convient module and evaluator `lib.collectPackages` packages.bonfire-docs: convient evaluators `nixosModulesDoc` and `packagesDoc` new: packages.postgresql: container image new: packages.redis: container image remove: packages.lego: needed dns provider was added to lego and nixpkgs packages.netgen: broken
59 lines
1.3 KiB
Nix
59 lines
1.3 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
bonLib,
|
|
extraPaths ? [],
|
|
...
|
|
}: let
|
|
user = "postgres";
|
|
dataDir = "/var/lib/postgresql";
|
|
entryPoint = pkgs.writeTextDir "entrypoint.sh" ''
|
|
initdb -U ${user}
|
|
postgres -k ${dataDir}
|
|
'';
|
|
in
|
|
pkgs.dockerTools.buildImage {
|
|
name = "postgresql";
|
|
tag = "latest";
|
|
|
|
copyToRoot = pkgs.buildEnv {
|
|
name = "image-root";
|
|
pathsToLink = ["/bin" "/etc" "/"];
|
|
paths = with pkgs;
|
|
[
|
|
bash
|
|
postgresql
|
|
entryPoint
|
|
]
|
|
++ extraPaths;
|
|
};
|
|
runAsRoot = with pkgs; ''
|
|
#!${runtimeShell}
|
|
${dockerTools.shadowSetup}
|
|
groupadd -r ${user}
|
|
useradd -r -g ${user} --home-dir=${dataDir} ${user}
|
|
mkdir -p ${dataDir}
|
|
chown -R ${user}:${user} ${dataDir}
|
|
'';
|
|
|
|
config = {
|
|
Entrypoint = ["bash" "/entrypoint.sh"];
|
|
StopSignal = "SIGINT";
|
|
User = "${user}:${user}";
|
|
Env = ["PGDATA=${dataDir}"];
|
|
WorkingDir = dataDir;
|
|
ExposedPorts = {
|
|
"5432/tcp" = {};
|
|
};
|
|
};
|
|
}
|
|
// {
|
|
meta = with lib; {
|
|
homepage = "https://www.postgresql.org";
|
|
description = "A powerful, open source object-relational database system.";
|
|
platforms = platforms.linux;
|
|
license = licenses.postgresql;
|
|
maintainers = with bonLib.maintainers; [L-Nafaryus];
|
|
};
|
|
}
|