97 lines
2.6 KiB
Nix
97 lines
2.6 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
config = lib.mkIf (config.beancloud.software.forgejo) {
|
|
beancloud.software.container = true;
|
|
|
|
environment.etc = {
|
|
"timezone" = {
|
|
text = config.time.timeZone;
|
|
};
|
|
};
|
|
|
|
virtualisation.oci-containers.containers = {
|
|
forgejo-frontend = {
|
|
image = "codeberg.org/forgejo/forgejo:11.0.3-rootless";
|
|
volumes = [
|
|
"forgejo_data:/data"
|
|
"/etc/timezone:/etc/timezone:ro"
|
|
"/etc/localtime:/etc/localtime:ro"
|
|
];
|
|
hostname = "forgejo";
|
|
networks = [
|
|
"forgejo"
|
|
];
|
|
ports = [
|
|
"127.0.0.1:3000:3000"
|
|
"127.0.0.1:2222:2222"
|
|
];
|
|
autoStart = true;
|
|
environment = {
|
|
FORGEJO__database__DB_TYPE = "mysql";
|
|
FORGEJO__database__HOST = "db:3306";
|
|
FORGEJO__database__NAME = "forgejo";
|
|
FORGEJO__database__USER = "forgejo";
|
|
FORGEJO__database__PASSWD = "forgejo";
|
|
};
|
|
dependsOn = [ "forgejo-backend" ];
|
|
};
|
|
forgejo-backend = {
|
|
image = "docker.io/library/mariadb:11.8.2";
|
|
volumes = [
|
|
"forgejo_db:/var/lib/mysql"
|
|
"/etc/timezone:/etc/timezone:ro"
|
|
"/etc/localtime:/etc/localtime:ro"
|
|
];
|
|
hostname = "db";
|
|
networks = [
|
|
"forgejo"
|
|
];
|
|
autoStart = true;
|
|
environment = {
|
|
MYSQL_ROOT_PASSWORD = "forgejo";
|
|
MYSQL_USER = "forgejo";
|
|
MYSQL_PASSWORD = "forgejo";
|
|
MYSQL_DATABASE = "forgejo";
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd.services."podman-forgejo-network" = {
|
|
path = [ pkgs.podman ];
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStop = "${pkgs.podman}/bin/podman network rm -f forgejo";
|
|
};
|
|
script = ''
|
|
podman network inspect forgejo || podman network create forgejo
|
|
'';
|
|
partOf = [ "podman-forgejo-root.target" ];
|
|
wantedBy = [ "podman-forgejo-root.target" ];
|
|
};
|
|
|
|
systemd.services."podman-forgejo-frontend" = {
|
|
partOf = [ "podman-forgejo-root.target" ];
|
|
wantedBy = [ "podman-forgejo-root.target" ];
|
|
};
|
|
|
|
systemd.services."podman-forgejo-backend" = {
|
|
partOf = [ "podman-forgejo-root.target" ];
|
|
wantedBy = [ "podman-forgejo-root.target" ];
|
|
};
|
|
|
|
systemd.targets."podman-forgejo-root" = {
|
|
unitConfig = {
|
|
Description = "root target: When started, this will automatically create all resources and start the containers. When stopped, this will teardown all resources.";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
};
|
|
}
|