Add pipeline for todo app deployment

This commit is contained in:
thiloho
2023-11-12 19:18:41 +01:00
parent f9376ebad2
commit eed097dc94
6 changed files with 61 additions and 15 deletions

21
flake.lock generated
View File

@@ -165,9 +165,30 @@
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"todos": "todos",
"website": "website" "website": "website"
} }
}, },
"todos": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1699811932,
"narHash": "sha256-HfzWtq2qBcjCnhWzDXdmaK5yNk49HapzJ0c+ER8RirA=",
"owner": "thiloho",
"repo": "todos",
"rev": "3e411cb41681d4dc69df85178c6d6550c7f63da3",
"type": "github"
},
"original": {
"owner": "thiloho",
"repo": "todos",
"type": "github"
}
},
"website": { "website": {
"flake": false, "flake": false,
"locked": { "locked": {

View File

@@ -20,6 +20,10 @@
url = "github:thiloho/discord-bot"; url = "github:thiloho/discord-bot";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
todos = {
url = "github:thiloho/todos";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";

View File

@@ -11,6 +11,7 @@
age.secrets.hedgedoc-environment-file.file = ../../secrets/hedgedoc-environment-file.age; age.secrets.hedgedoc-environment-file.file = ../../secrets/hedgedoc-environment-file.age;
age.secrets.discord-bot-token.file = ../../secrets/discord-bot-token.age; age.secrets.discord-bot-token.file = ../../secrets/discord-bot-token.age;
age.secrets.todos-environment-file.file = ../../secrets/todos-environment-file.age;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
nodejs_20 nodejs_20
@@ -79,6 +80,11 @@
extraConfig = "proxy_ssl_server_name on;"; extraConfig = "proxy_ssl_server_name on;";
}; };
}; };
"todos.thilohohlt.com" = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://localhost:5173";
};
}; };
}; };
hedgedoc = { hedgedoc = {
@@ -101,7 +107,7 @@
postgresql = { postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_15; package = pkgs.postgresql_15;
ensureDatabases = [ "dcbot" "hedgedoc" ]; ensureDatabases = [ "dcbot" "hedgedoc" "todos" ];
ensureUsers = [ ensureUsers = [
{ {
name = "hedgedoc"; name = "hedgedoc";
@@ -125,19 +131,33 @@
''; '';
}; };
systemd.services.denbot = { systemd.services = {
description = "Thilo's Den discord bot"; todoapp = {
wantedBy = ["multi-user.target"]; description = "Todo application to plan your daily tasks effectively";
after = ["network-online.target"]; wantedBy = ["multi-user.target"];
serviceConfig = { wants = ["network-online.target"];
Type = "simple"; serviceConfig = {
ExecStartPre = [ Type = "simple";
"${pkgs.nodejs_20}/bin/node dbInit.js" Environment = "PORT=5173 DOTENV_CONFIG_PATH=${config.age.secrets.todos-environment-file.path}";
"${pkgs.nodejs_20}/bin/node deploy-commands.js --token=${config.age.secrets.discord-bot-token.path} --clientId=1142441791459704912" ExecStart = "${pkgs.nodejs_20}/bin/node -r dotenv/config .";
]; WorkingDirectory = inputs.todos.packages.${pkgs.system}.default;
ExecStart = "${pkgs.nodejs_20}/bin/node index.js --token=${config.age.secrets.discord-bot-token.path}"; Restart = "always";
WorkingDirectory = inputs.denbot.packages.${pkgs.system}.default; };
Restart = "always"; };
denbot = {
description = "Thilo's Den discord bot";
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
serviceConfig = {
Type = "simple";
ExecStartPre = [
"${pkgs.nodejs_20}/bin/node dbInit.js"
"${pkgs.nodejs_20}/bin/node deploy-commands.js --token=${config.age.secrets.discord-bot-token.path} --clientId=1142441791459704912"
];
ExecStart = "${pkgs.nodejs_20}/bin/node index.js --token=${config.age.secrets.discord-bot-token.path}";
WorkingDirectory = inputs.denbot.packages.${pkgs.system}.default;
Restart = "always";
};
}; };
}; };

View File

@@ -5,4 +5,5 @@ in
{ {
"hedgedoc-environment-file.age".publicKeys = [ server pc ]; "hedgedoc-environment-file.age".publicKeys = [ server pc ];
"discord-bot-token.age".publicKeys = [ server pc ]; "discord-bot-token.age".publicKeys = [ server pc ];
"todos-environment-file.age".publicKeys = [ server pc ];
} }

Binary file not shown.