119 lines
3.6 KiB
Nix
119 lines
3.6 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
let
|
|
containerName = "gitea";
|
|
composeFile = "podman/gitea/compose.yaml";
|
|
configDir = "/mnt/config/gitea";
|
|
dataDir = "gitea_data";
|
|
in
|
|
|
|
{
|
|
config = {
|
|
environment.etc."${compose_file}".text =
|
|
/*
|
|
yaml
|
|
*/
|
|
''
|
|
services:
|
|
gitea-server:
|
|
image: docker.gitea.com/gitea:latest-rootless
|
|
container_name: gitea-server
|
|
hostname: gitea-server
|
|
networks:
|
|
gitea_frontend:
|
|
gitea_backend:
|
|
ports:
|
|
- "3000:3000/tcp" #http
|
|
volumes:
|
|
- gitea_data:/var/lib/gitea
|
|
- ${configDir}:/etc/gitea
|
|
- /etc/localtime:/etc/localtime:ro
|
|
environment:
|
|
- GITEA__database__DB_TYPE=postgres
|
|
- GITEA__database__HOST=$POSTGRES_HOST:$POSTGRES_PORT
|
|
- GITEA__database__NAME=$DB_NAME
|
|
- GITEA__database__USER=$DB_USERNAME
|
|
- GITEA__database__PASSWD=$DB_PASSWORD
|
|
- GITEA__server__SSH_PORT=2424
|
|
- GITEA__server__ROOT_URL=gitea.$DOMAIN_NAME
|
|
depends_on:
|
|
- gitea-database
|
|
restart: unless-stopped
|
|
|
|
gitea-database:
|
|
image: docker.io/library/postgres:14
|
|
container_name: gitea-database
|
|
hostname: gitea-database
|
|
networks:
|
|
gitea_backend:
|
|
volumes:
|
|
- gitea_database:/var/lib/postgresql/data
|
|
environment:
|
|
- POSTGRES_USER=$DB_USERNAME
|
|
- POSTGRES_PASSWORD=$DB_PASSWORD
|
|
- POSTGRES_DB=$DB_NAME
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
gitea_data:
|
|
gitea_database:
|
|
|
|
networks:
|
|
gitea_frontend:
|
|
name: gitea_frontend
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: "10.89.3.0/24"
|
|
gateway: "10.89.3.254"
|
|
gitea_backend:
|
|
name: gitea_backend
|
|
driver: bridge
|
|
ipam:
|
|
config:
|
|
- subnet: "10.89.4.0/24"
|
|
gateway: "10.89.4.254"
|
|
'';
|
|
|
|
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 = "900";
|
|
ExecStartPre = [
|
|
"${pkgs.bash}/bin/bash -c 'sleep $((RANDOM % 400))'"
|
|
"-${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" ];
|
|
};
|
|
};
|
|
} |