Created a helper to create the container configurations. Updated all containers files to use it.
This commit is contained in:
@@ -1,77 +1,37 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
container_name = "it-tools";
|
||||
compose_file = "podman/it-tools/compose.yaml";
|
||||
helper = import ./lib.nix { inherit config pkgs lib; };
|
||||
cfg = config.numbus.services.it-tools;
|
||||
in
|
||||
|
||||
{
|
||||
config = {
|
||||
environment.etc."${compose_file}".text =
|
||||
/*
|
||||
yaml
|
||||
*/
|
||||
''
|
||||
services:
|
||||
it-tools:
|
||||
container_name: it-tools
|
||||
image: corentinth/it-tools
|
||||
networks:
|
||||
it-tools_frontend:
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.docker.network=it-tools_frontend
|
||||
- traefik.http.services.it-tools.loadbalancer.server.port=80
|
||||
- traefik.http.services.it-tools.loadbalancer.server.scheme=http
|
||||
- traefik.http.routers.it-tools-https.entrypoints=websecure
|
||||
- traefik.http.routers.it-tools-https.rule=Host(`it-tools.$DOMAIN_NAME`)
|
||||
- traefik.http.routers.it-tools-https.tls=true
|
||||
- traefik.http.routers.it-tools-https.tls.certresolver=cloudflare
|
||||
restart: unless-stopped
|
||||
helper.mkPodmanService {
|
||||
name = "it-tools";
|
||||
description = "Immich, Google Photos but better";
|
||||
defaultPort = "8880";
|
||||
pod = "false";
|
||||
|
||||
composeText = ''
|
||||
services:
|
||||
it-tools:
|
||||
image: docker.io/corentinth/it-tools:latest
|
||||
container_name: it-tools
|
||||
hostname: it-tools
|
||||
networks:
|
||||
it-tools_frontend:
|
||||
external: true
|
||||
'';
|
||||
ports:
|
||||
- "${cfg.port}:80/tcp"
|
||||
restart: unless-stopped
|
||||
|
||||
systemd.services."${container_name}" = {
|
||||
description = "Podman container : ${container_name}";
|
||||
after = [ "network.target" "traefik.service" "pi-hole.service" ];
|
||||
requires = [ "traefik.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.podman pkgs.coreutils ];
|
||||
|
||||
serviceConfig = {
|
||||
User = "numbus-admin";
|
||||
Environment = [ "XDG_RUNTIME_DIR=/run/user/1000" ];
|
||||
Type = "exec";
|
||||
TimeoutStartSec = "600";
|
||||
ExecStartPre = [
|
||||
"${pkgs.bash}/bin/bash -c 'sleep $((RANDOM % 180))'"
|
||||
"-${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} pull"
|
||||
];
|
||||
ExecStart = "${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} up --remove-orphans";
|
||||
ExecStop = "${pkgs.podman-compose}/bin/podman-compose -f /etc/${compose_file} down";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5m";
|
||||
StartLimitBurst = "3";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."update-${container_name}" = {
|
||||
description = "Update ${container_name} container";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.systemd}/bin/systemctl restart ${container_name}.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.timers."update-${container_name}" = {
|
||||
timerConfig = {
|
||||
OnCalendar = "02:00";
|
||||
RandomizedDelaySec = "60m";
|
||||
Unit = "update-${container_name}.service";
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
networks:
|
||||
it-tools_frontend:
|
||||
name: it-tools_frontend
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: "10.89.9.0/24"
|
||||
gateway: "10.89.9.254"
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user