From eed097dc9489c11054bafbd704fefb8feb4e5a80 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 12 Nov 2023 19:18:41 +0100 Subject: [PATCH] Add pipeline for todo app deployment --- flake.lock | 21 +++++++++++ flake.nix | 4 ++ nixos-configurations/server/default.nix | 48 +++++++++++++++++------- secrets/hedgedoc-environment-file.age | Bin 587 -> 562 bytes secrets/secrets.nix | 3 +- secrets/todos-environment-file.age | Bin 0 -> 723 bytes 6 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 secrets/todos-environment-file.age diff --git a/flake.lock b/flake.lock index c6dc63b..b48e156 100644 --- a/flake.lock +++ b/flake.lock @@ -165,9 +165,30 @@ "home-manager": "home-manager_2", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", + "todos": "todos", "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": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index fdf8383..124d06a 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,10 @@ url = "github:thiloho/discord-bot"; inputs.nixpkgs.follows = "nixpkgs"; }; + todos = { + url = "github:thiloho/todos"; + inputs.nixpkgs.follows = "nixpkgs"; + }; agenix = { url = "github:ryantm/agenix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/nixos-configurations/server/default.nix b/nixos-configurations/server/default.nix index 798eb5e..317c16d 100644 --- a/nixos-configurations/server/default.nix +++ b/nixos-configurations/server/default.nix @@ -11,6 +11,7 @@ age.secrets.hedgedoc-environment-file.file = ../../secrets/hedgedoc-environment-file.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; [ nodejs_20 @@ -79,6 +80,11 @@ extraConfig = "proxy_ssl_server_name on;"; }; }; + "todos.thilohohlt.com" = { + enableACME = true; + forceSSL = true; + locations."/".proxyPass = "http://localhost:5173"; + }; }; }; hedgedoc = { @@ -101,7 +107,7 @@ postgresql = { enable = true; package = pkgs.postgresql_15; - ensureDatabases = [ "dcbot" "hedgedoc" ]; + ensureDatabases = [ "dcbot" "hedgedoc" "todos" ]; ensureUsers = [ { name = "hedgedoc"; @@ -125,19 +131,33 @@ ''; }; - systemd.services.denbot = { - description = "Thilo's Den discord bot"; - wantedBy = ["multi-user.target"]; - after = ["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"; + systemd.services = { + todoapp = { + description = "Todo application to plan your daily tasks effectively"; + wantedBy = ["multi-user.target"]; + wants = ["network-online.target"]; + serviceConfig = { + Type = "simple"; + Environment = "PORT=5173 DOTENV_CONFIG_PATH=${config.age.secrets.todos-environment-file.path}"; + ExecStart = "${pkgs.nodejs_20}/bin/node -r dotenv/config ."; + WorkingDirectory = inputs.todos.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"; + }; }; }; diff --git a/secrets/hedgedoc-environment-file.age b/secrets/hedgedoc-environment-file.age index d00cb532f058a76d8b1295052fb4151142ecd918..b56f3ce8d2eae0e0e23378bee7371fd968a7e0cd 100644 GIT binary patch delta 529 zcmX@jvWaDaPJMo8RHadNSyH-ZPKuXbW>QvUd5VW;T2f(ENQiexnQ^9Lo};#RRC+~d zK9_g6MX*VzS8kG_hh>UqQKX4`Mp$NfaZqAdMYeWDq-(K}zPGtwZgy#oE0?aFLUD11 zZfc5=si~o*LP}7ML2#f#ijTjsNoaYdb6|c&qDg3gf4yaidx()!g+Yj+Q)*U}ev(e6ys0$RHQjyb6D(iWGy8sInvC%*`HuQZda#DGY% z;(TovCyy|5GlPg^*T}#USK~_K2!kl+axPt6U4<&+aHm336Bj?HlA@vrGt=M-?X-~G zaF;^o?97sU$Kder+^|$5$K;SA6E0KsFPj0x9k%iqlDS=_wApvHE&T~&Bha#zieB0{rQ8LZf8~>*~W4{rS2k6qN>*I z1v4LPD!ceUlv^Ro)}EI=&P?g~>dKwY?N*7+o8GKeWP9kb{Y-1<4l^{IR) Xb`7gpZ^*(GA185j*PjcMoK^tR^l7(|_mam_Cnu%vtutj*DalWT7 z$U2=eqe|WMqSVCVRE6?*PZi}V9Z#;5&=i9J_o__8aAT8PrzFSJ(vaffsO+MUsuZ74 zUzgJQY<)jN|5O*h%#x_=@`8d4FH1|ysNnRVAjkAjbM3qcu9DQ^j8b!VgB;To$1)2a zeMA4E;(Ws@w=6>wmsA(`@SMOzeP91#H*bH#WY@fsB*S3OP>GUdgaM4uf@YAVT8-qrvB@j%Ig diff --git a/secrets/secrets.nix b/secrets/secrets.nix index a4aeddf..77c6b97 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -5,4 +5,5 @@ in { "hedgedoc-environment-file.age".publicKeys = [ server pc ]; "discord-bot-token.age".publicKeys = [ server pc ]; -} \ No newline at end of file + "todos-environment-file.age".publicKeys = [ server pc ]; +} diff --git a/secrets/todos-environment-file.age b/secrets/todos-environment-file.age new file mode 100644 index 0000000000000000000000000000000000000000..be0b1b0da6a9c7f0cc3e8b68fe52d66943d71603 GIT binary patch literal 723 zcmYdHPt{G$OD?J`D9Oyv)5|YP*Do{V(zR14F3!+RO))YxHMCU7FAqz1aa8asE3mW( z^zkO}^bXe#NKG#EFix*ZO-?m04N3RV&UH6;cjXE<&PplCH}T8K4l(nq zEXdV2E$|E|_H=c#Om->@_O6J?)lMpjFi7@r^+dNVB`C)rI8Y(CI43Y7pfobu%&gL@ z($F&^B_P;8GPTgKRNKTm%f;8NB-Ai6ASWp&B%3SCvLLkBGubq~!pG90sK_zRKgY2= zJhIF+$tTUjJFqa*ATuev*f=oUIU8h~qOG5Ce#`N#op8H4AdjHL6^FB4NBjDuLOIJ28 zR$1Jilsy0TMC(|W$WO}id${?huI71oaL?iAG3lI>!%p2-$>ci|IpJ@S4P&LJ;(|a{ zwgmqP+poskmiwEYDXZ7md&%jb+!XoShc=iBr_Eh2XT`pJp03yu-|5On`f|Tn>Tkaf E0Kal1{r~^~ literal 0 HcmV?d00001