aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-08-06 01:38:35 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-09-30 00:37:01 +0200
commit2e573da3e091144d7d6f8c72021a8602fb71d61f (patch)
tree92e81fe3728b7130123f447a0a1f79feaf1f4918 /modules
parenta9f52ec521e45204ad9363dd143b32ac9910b6b3 (diff)
downloadNix-2e573da3e091144d7d6f8c72021a8602fb71d61f.tar.gz
Nix-2e573da3e091144d7d6f8c72021a8602fb71d61f.tar.zst
Nix-2e573da3e091144d7d6f8c72021a8602fb71d61f.zip
Site de Bingo de Denise
Diffstat (limited to 'modules')
-rw-r--r--modules/private/buildbot/projects/denise/__init__.py50
-rw-r--r--modules/private/default.nix1
-rw-r--r--modules/private/websites/default.nix1
-rw-r--r--modules/private/websites/denise/bingo.nix100
4 files changed, 151 insertions, 1 deletions
diff --git a/modules/private/buildbot/projects/denise/__init__.py b/modules/private/buildbot/projects/denise/__init__.py
index 2a19ef5..abeba3c 100644
--- a/modules/private/buildbot/projects/denise/__init__.py
+++ b/modules/private/buildbot/projects/denise/__init__.py
@@ -14,6 +14,10 @@ class E():
14 SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key" 14 SSH_KEY_PATH = "/var/lib/buildbot/buildbot_key"
15 SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF" 15 SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF"
16 16
17 BINGO_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/bingo"
18 BINGO_BETA_PATH = "/var/lib/buildbot/outputs/denise/bingo_beta"
19 BINGO_GIT_URL = "gitolite@git.immae.eu:perso/Denise/bingo"
20
17 OMS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/oms" 21 OMS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/oms"
18 OMS_BETA_PATH = "/var/lib/buildbot/outputs/denise/oms_beta" 22 OMS_BETA_PATH = "/var/lib/buildbot/outputs/denise/oms_beta"
19 OMS_GIT_URL = "gitolite@git.immae.eu:perso/Denise/oms" 23 OMS_GIT_URL = "gitolite@git.immae.eu:perso/Denise/oms"
@@ -54,15 +58,59 @@ def configure(c):
54 } 58 }
55 c['workers'].append(worker.LocalWorker("generic-worker-denise")) 59 c['workers'].append(worker.LocalWorker("generic-worker-denise"))
56 60
61 c['schedulers'].append(hook_scheduler("DeniseBingo", timer=1))
57 c['schedulers'].append(hook_scheduler("DeniseOMS", timer=1)) 62 c['schedulers'].append(hook_scheduler("DeniseOMS", timer=1))
58 c['schedulers'].append(hook_scheduler("DeniseAventuriers", timer=1)) 63 c['schedulers'].append(hook_scheduler("DeniseAventuriers", timer=1))
59 c['schedulers'].append(force_scheduler("force_denise", [ 64 c['schedulers'].append(force_scheduler("force_denise", [
60 "DeniseOMS_build", "DeniseAventuriers_build" 65 "DeniseBingo_build", "DeniseOMS_build", "DeniseAventuriers_build"
61 ])) 66 ]))
62 67
63 c['builders'].append(denise_oms_factory()) 68 c['builders'].append(denise_oms_factory())
69 c['builders'].append(denise_bingo_factory())
64 c['builders'].append(denise_aventuriers_factory()) 70 c['builders'].append(denise_aventuriers_factory())
65 71
72def denise_bingo_factory():
73 @util.renderer
74 def bingo_run_path(props):
75 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
76 return "/run/denise_bingo/gunicorn.pid"
77 else:
78 return "/run/denise_bingo_beta/gunicorn.pid"
79
80 @util.renderer
81 def bingo_systemd_service(props):
82 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
83 return "denise-bingo"
84 else:
85 return "denise-bingo-beta"
86
87 @util.renderer
88 def bingo_url(props):
89 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
90 return "https://bingo.syanni.eu"
91 else:
92 return "https://beta.bingo.syanni.eu"
93
94 @util.renderer
95 def bingo_path(props):
96 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
97 return E.BINGO_RELEASE_PATH
98 else:
99 return E.BINGO_BETA_PATH
100
101 factory = util.BuildFactory()
102 factory.addStep(steps.Git(logEnviron=False, repourl=E.BINGO_GIT_URL,
103 submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
104 sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
105 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("rm -rf %(kw:bingo_path)s", bingo_path=bingo_path)))
106 factory.addStep(steps.DirectoryUpload(workersrc="../source",
107 masterdest=bingo_path,
108 url=bingo_url))
109 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("chmod -R a+rX %(kw:bingo_path)s", bingo_path=bingo_path)))
110 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("/run/wrappers/bin/sudo systemctl restart %(kw:bingo_service)s.service", bingo_service=bingo_systemd_service)))
111
112 return util.BuilderConfig(name="DeniseBingo_build", workernames=["generic-worker-denise"], factory=factory)
113
66def denise_oms_factory(): 114def denise_oms_factory():
67 @util.renderer 115 @util.renderer
68 def oms_run_path(props): 116 def oms_run_path(props):
diff --git a/modules/private/default.nix b/modules/private/default.nix
index 0ff5214..6b64e60 100644
--- a/modules/private/default.nix
+++ b/modules/private/default.nix
@@ -35,6 +35,7 @@ set = {
35 deniseDenisejeromeProd = ./websites/denise/denisejerome.nix; 35 deniseDenisejeromeProd = ./websites/denise/denisejerome.nix;
36 deniseEvariste = ./websites/denise/evariste.nix; 36 deniseEvariste = ./websites/denise/evariste.nix;
37 deniseOMS = ./websites/denise/oms.nix; 37 deniseOMS = ./websites/denise/oms.nix;
38 deniseBingo = ./websites/denise/bingo.nix;
38 deniseAventuriers = ./websites/denise/aventuriers.nix; 39 deniseAventuriers = ./websites/denise/aventuriers.nix;
39 deniseProduction = ./websites/denise/production.nix; 40 deniseProduction = ./websites/denise/production.nix;
40 41
diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix
index fa9ee8d..ba2dde0 100644
--- a/modules/private/websites/default.nix
+++ b/modules/private/websites/default.nix
@@ -243,6 +243,7 @@ in
243 evariste.enable = true; 243 evariste.enable = true;
244 denisejerome.enable = true; 244 denisejerome.enable = true;
245 oms.enable = true; 245 oms.enable = true;
246 bingo.enable = true;
246 aventuriers.enable = true; 247 aventuriers.enable = true;
247 production.enable = true; 248 production.enable = true;
248 }; 249 };
diff --git a/modules/private/websites/denise/bingo.nix b/modules/private/websites/denise/bingo.nix
new file mode 100644
index 0000000..9130462
--- /dev/null
+++ b/modules/private/websites/denise/bingo.nix
@@ -0,0 +1,100 @@
1{ lib, config, pkgs, ... }:
2let
3 cfg = config.myServices.websites.denise.bingo;
4 varDir = "/var/lib/buildbot/outputs/denise/bingo";
5 varDirBeta = "/var/lib/buildbot/outputs/denise/bingo_beta";
6 socket = "/run/denise_bingo/socket.sock";
7 socket_beta = "/run/denise_bingo_beta/socket.sock";
8in {
9 options.myServices.websites.denise.bingo.enable = lib.mkEnableOption "enable Denise's bingo website";
10
11 config = lib.mkIf cfg.enable {
12 services.websites.env.production.vhostConfs.denise_bingo = {
13 certName = "denise";
14 addToCerts = true;
15 hosts = [ "bingo.syanni.eu" ];
16 root = null;
17 extraConfig = [
18 ''
19 ProxyPreserveHost on
20 ProxyVia On
21 ProxyRequests Off
22 ProxyPassMatch ^/.well-known/acme-challenge !
23 ProxyPass / unix://${socket}|http://bingo.syanni.eu/
24 ProxyPassReverse / unix://${socket}|http://bingo.syanni.eu/
25 ''
26 ];
27 };
28
29 systemd.services.denise-bingo = {
30 description = "Denise bingo website";
31 after = [ "network.target" ];
32 wantedBy = [ "multi-user.target" ];
33
34 serviceConfig = {
35 Type = "simple";
36 WorkingDirectory = varDir;
37 ExecStart = let
38 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
39 in
40 "${python}/bin/gunicorn -w4 -p /run/denise_bingo/gunicorn.pid --bind unix:${socket} app:app";
41 User = "wwwrun";
42 Restart = "always";
43 RestartSec = "5s";
44 PIDFile = "/run/denise_bingo/gunicorn.pid";
45 RuntimeDirectory = "denise_bingo";
46 StandardOutput = "journal";
47 StandardError = "inherit";
48 };
49 };
50
51 security.sudo.extraRules = [
52 {
53 commands = [
54 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-bingo-beta.service"; }
55 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-bingo.service"; }
56 ];
57 users = ["buildbot"];
58 runAs = "root";
59 }
60 ];
61 services.websites.env.integration.vhostConfs.denise_bingo_beta = {
62 certName = "denise";
63 addToCerts = true;
64 hosts = [ "beta.bingo.syanni.eu" ];
65 root = null;
66 extraConfig = [
67 ''
68 ProxyPreserveHost on
69 ProxyVia On
70 ProxyRequests Off
71 ProxyPassMatch ^/.well-known/acme-challenge !
72 ProxyPass / unix://${socket_beta}|http://beta.bingo.syanni.eu/
73 ProxyPassReverse / unix://${socket_beta}|http://beta.bingo.syanni.eu/
74 ''
75 ];
76 };
77
78 systemd.services.denise-bingo-beta = {
79 description = "Denise bingo beta website";
80 after = [ "network.target" ];
81 wantedBy = [ "multi-user.target" ];
82
83 serviceConfig = {
84 Type = "simple";
85 WorkingDirectory = varDirBeta;
86 ExecStart = let
87 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask ]);
88 in
89 "${python}/bin/gunicorn -w4 -p /run/denise_bingo_beta/gunicorn.pid --bind unix:${socket_beta} app:app";
90 User = "wwwrun";
91 Restart = "always";
92 RestartSec = "5s";
93 PIDFile = "/run/denise_bingo_beta/gunicorn.pid";
94 RuntimeDirectory = "denise_bingo_beta";
95 StandardOutput = "journal";
96 StandardError = "inherit";
97 };
98 };
99 };
100}