Docker and postgres config
This commit is contained in:
parent
5b8a1430fe
commit
5205e606c1
|
@ -0,0 +1,20 @@
|
|||
{ inputs, ... }: {
|
||||
|
||||
imports = [ inputs.arion.nixosModules.arion ];
|
||||
# Arion works with Docker, but for NixOS-based containers, you need Podman
|
||||
# since NixOS 21.05.
|
||||
virtualisation = {
|
||||
podman = {
|
||||
enable = true;
|
||||
defaultNetwork.settings.dns_enabled = true;
|
||||
};
|
||||
docker = {
|
||||
storageDriver = "btrfs";
|
||||
rootless = {
|
||||
enable = true;
|
||||
setSocketVariable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
virtualisation.arion = {
|
||||
backend = "docker";
|
||||
projects = {
|
||||
"db".settings.services."db".service = {
|
||||
image = "postgres:16";
|
||||
restart = "unless-stopped";
|
||||
environment = {
|
||||
POSTGRES_PASSWORD = "balls1234";
|
||||
POSTGRES_USER = "admin";
|
||||
POSTGRES_DATABASE = "test_db";
|
||||
};
|
||||
ports = [ "5432:5432" ];
|
||||
volumes = [
|
||||
"/mnt/postgres/data:/var/lib/postgres/data"
|
||||
"${pkgs.writeScript "load_extensions" ''
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<EOF
|
||||
create extension postgis;
|
||||
select * FROM pg_extension;
|
||||
EOF
|
||||
''}:/docker-entrypoint-initdb.d/"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue