1
Fork 0

Set up self hosted 5d diplomacy

This commit is contained in:
prescientmoon 2024-10-11 14:12:05 +02:00
parent 404f6c8d3e
commit 536929ec41
Signed by: prescientmoon
SSH key fingerprint: SHA256:WFp/cO76nbarETAoQcQXuV+0h7XJsEsOCI0UsyPIy6U
5 changed files with 170 additions and 4 deletions

View file

@ -25,5 +25,6 @@
guacamole = 8421;
syncthing = 8422;
forgejo-ssh = 8423;
"5d-diplomacy" = 8424;
};
}

View file

@ -1,6 +1,11 @@
{
virtualisation.oci-containers.backend = "docker";
virtualisation.docker = {
enable = true;
autoPrune.enable = true;
};
environment.persistence = {
"/persist/state".directories = [ "/var/lib/containers/storage" ];
"/persist/local/cache".directories = [ "/var/lib/containers/cache" ];

View file

@ -19,14 +19,16 @@
# ./services/commafeed.nix
# ./services/ddclient.nix
# ./services/guacamole
# ./services/intray.nix
# ./services/smos.nix
./services/5d-diplomacy
./services/actual.nix
./services/cloudflared.nix
./services/diptime.nix
./services/forgejo.nix
./services/grafana.nix
./services/guacamole
./services/homer.nix
# ./services/intray.nix
./services/invidious.nix
./services/jellyfin.nix
./services/jupyter.nix
@ -34,10 +36,9 @@
./services/pounce.nix
./services/prometheus.nix
./services/prometheus.nix
./services/qbittorrent.nix # turned on/off depending on whether my vpn is paid for
./services/qbittorrent.nix
./services/radicale.nix
./services/redlib.nix
# ./services/smos.nix
./services/vaultwarden.nix
./services/whoogle.nix
./services/zfs.nix

View file

@ -0,0 +1,9 @@
{ config, ... }:
{
imports = [ ./generated.nix ];
satellite.cloudflared.at.dip.port = config.satellite.ports."5d-diplomacy";
virtualisation.oci-containers.containers."5d-diplomacy-frontend".ports = [
"${toString config.satellite.ports."5d-diplomacy"}:8080"
];
}

View file

@ -0,0 +1,150 @@
# Auto-generated using compose2nix v0.3.1-pre.
{ pkgs, lib, ... }:
{
# Containers
virtualisation.oci-containers.containers."5d-diplomacy-backend" = {
image = "localhost/compose2nix-5d-diplomacy-backend";
environment = {
"ConnectionStrings__Database" = "Server=mssql;Database=diplomacy;User=SA;Password=Passw0rd@;Encrypt=True;TrustServerCertificate=True";
};
log-driver = "journald";
extraOptions = [
"--network-alias=backend"
"--network=5d-diplomacy_default"
];
};
systemd.services."docker-5d-diplomacy-backend" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
RestartMaxDelaySec = lib.mkOverride 90 "1m";
RestartSec = lib.mkOverride 90 "100ms";
RestartSteps = lib.mkOverride 90 9;
};
after = [
"docker-build-5d-diplomacy-backend.service"
"docker-network-5d-diplomacy_default.service"
];
requires = [
"docker-build-5d-diplomacy-backend.service"
"docker-network-5d-diplomacy_default.service"
];
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
virtualisation.oci-containers.containers."5d-diplomacy-frontend" = {
image = "localhost/compose2nix-5d-diplomacy-frontend";
ports = [ "127.0.0.1:5173:8080/tcp" ];
log-driver = "journald";
extraOptions = [
"--network-alias=frontend"
"--network=5d-diplomacy_default"
];
};
systemd.services."docker-5d-diplomacy-frontend" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
RestartMaxDelaySec = lib.mkOverride 90 "1m";
RestartSec = lib.mkOverride 90 "100ms";
RestartSteps = lib.mkOverride 90 9;
};
after = [
"docker-build-5d-diplomacy-frontend.service"
"docker-network-5d-diplomacy_default.service"
];
requires = [
"docker-build-5d-diplomacy-frontend.service"
"docker-network-5d-diplomacy_default.service"
];
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
virtualisation.oci-containers.containers."5d-diplomacy-mssql" = {
image = "mcr.microsoft.com/mssql/server:2022-latest";
environment = {
"ACCEPT_EULA" = "y";
"MSSQL_SA_PASSWORD" = "Passw0rd@";
};
volumes = [
"/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/data:/var/opt/mssql/data:rw"
"/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/log:/var/opt/mssql/log:rw"
"/home/moon/projects/5d-diplomacy-with-multiverse-time-travel/mssql-data/secrets:/var/opt/mssql/secrets:rw"
];
user = "root";
log-driver = "journald";
extraOptions = [
"--network-alias=mssql"
"--network=5d-diplomacy_default"
];
};
systemd.services."docker-5d-diplomacy-mssql" = {
serviceConfig = {
Restart = lib.mkOverride 90 "no";
};
after = [ "docker-network-5d-diplomacy_default.service" ];
requires = [ "docker-network-5d-diplomacy_default.service" ];
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
# Networks
systemd.services."docker-network-5d-diplomacy_default" = {
path = [ pkgs.docker ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStop = "docker network rm -f 5d-diplomacy_default";
};
script = ''
docker network inspect 5d-diplomacy_default || docker network create 5d-diplomacy_default
'';
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
# Builds
systemd.services."docker-build-5d-diplomacy-backend" = {
path = [
pkgs.docker
pkgs.git
];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
TimeoutSec = 300;
};
script = ''
cd /home/moon/projects/5d-diplomacy-with-multiverse-time-travel/server
docker build -t compose2nix-5d-diplomacy-backend .
'';
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
systemd.services."docker-build-5d-diplomacy-frontend" = {
path = [
pkgs.docker
pkgs.git
];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
TimeoutSec = 300;
};
script = ''
cd /home/moon/projects/5d-diplomacy-with-multiverse-time-travel/client
docker build -t compose2nix-5d-diplomacy-frontend .
'';
partOf = [ "docker-compose-5d-diplomacy-root.target" ];
wantedBy = [ "docker-compose-5d-diplomacy-root.target" ];
};
# Root service
# When started, this will automatically create all resources and start
# the containers. When stopped, this will teardown all resources.
systemd.targets."docker-compose-5d-diplomacy-root" = {
unitConfig = {
Description = "Root target generated by compose2nix.";
};
wantedBy = [ "multi-user.target" ];
};
}