make ghost work on podman

This commit is contained in:
cy 2024-12-17 02:09:57 -05:00
parent dff837606b
commit 4fc952c732
3 changed files with 35 additions and 11 deletions

View file

@ -11,6 +11,13 @@
password = "$2y$10$BZy2zYJj5z4e8LZCq/GwuuhWUafL/MNFO.YcsAMmpDS.2krPxi7KC"; password = "$2y$10$BZy2zYJj5z4e8LZCq/GwuuhWUafL/MNFO.YcsAMmpDS.2krPxi7KC";
} }
]; ];
# do not listen eveywhere cause podman runs it's own DNS
dns.bind_hosts = [
"127.0.0.1"
"::1"
"31.59.129.225"
"2a0f:85c1:840:2bfb::1"
];
}; };
}; };
} }

View file

@ -172,13 +172,16 @@
}; };
# container stuff # container stuff
virtualisation.container.enable = true; virtualisation.containers.enable = true;
vrtualisation.podman = { virtualisation.podman = {
enable = true; enable = true;
# create 'docker' alias for podman, to use as # create 'docker' alias for podman, to use as
# drop-in replacement # drop-in replacement
dockerCompat = true; dockerCompat = true;
defaultNetwork.settings.dns_enabled = true; defaultNetwork.settings = {
dns_enabled = true;
ipv6_enabled = true;
};
}; };
virtualisation.oci-containers.backend = "podman"; virtualisation.oci-containers.backend = "podman";
} }

View file

@ -1,9 +1,13 @@
{...}: { {
pkgs,
config,
...
}: {
virtualisation.oci-containers.containers.ghost = { virtualisation.oci-containers.containers.ghost = {
imgage = "ghost:5-alpine"; image = "ghost:5-alpine";
autoStart = true; autoStart = true;
ports = ["127.0.0.1:8084:2368"]; ports = ["127.0.0.1:8084:2368"];
pull = "always"; pull = "newer";
environment = { environment = {
database__client = "mysql"; database__client = "mysql";
database__connection__host = "ghost-db"; database__connection__host = "ghost-db";
@ -16,22 +20,32 @@
volumes = [ volumes = [
"/opt/ghost/data:/var/lib/ghost/content" "/opt/ghost/data:/var/lib/ghost/content"
]; ];
networks = [ networks = ["ghost-net"];
"ghost-net" dependsOn = ["ghost-db"];
];
}; };
virtualisation.oci-containers.containers.ghost-db = { virtualisation.oci-containers.containers.ghost-db = {
image = "mysql:8.0"; image = "mysql:8.0";
autoStart = true; autoStart = true;
pull = "newer";
environment = { environment = {
MYSQL_ROOT_PASSWORD = "example"; MYSQL_ROOT_PASSWORD = "example";
}; };
volumes = [ volumes = [
"/opt/ghost/db:/var/lib/mysql" "/opt/ghost/db:/var/lib/mysql"
]; ];
networks = [ networks = ["ghost-net"];
"ghost-net" };
systemd.services.create-ghost-net = {
serviceConfig.Type = "oneshot";
wantedBy = with config.virtualisation.oci-containers; [
"${backend}-ghost.service"
"${backend}-ghost-db.service"
]; ];
script = ''
${pkgs.podman}/bin/podman network exists ghost-net || \
${pkgs.podman}/bin/podman network create ghost-net
'';
}; };
} }