infrastructure/machines/storage01/garage.nix
Ryan Lahfa 12b20e6acf
Some checks failed
Check meta / check_meta (pull_request) Successful in 17s
Check meta / check_dns (pull_request) Successful in 17s
build configuration / build_and_cache_geo01 (pull_request) Successful in 1m8s
build configuration / build_and_cache_storage01 (pull_request) Successful in 1m21s
build configuration / build_and_cache_geo02 (pull_request) Successful in 1m9s
build configuration / build_and_cache_rescue01 (pull_request) Successful in 1m26s
build configuration / build_and_cache_compute01 (pull_request) Successful in 1m33s
build configuration / build_and_cache_krz01 (pull_request) Successful in 2m1s
lint / check (pull_request) Successful in 25s
build configuration / build_and_cache_vault01 (pull_request) Successful in 1m15s
build configuration / build_and_cache_bridge01 (pull_request) Successful in 1m6s
build configuration / build_and_cache_web02 (pull_request) Successful in 1m13s
build configuration / build_and_cache_web01 (pull_request) Successful in 1m42s
Check meta / check_meta (push) Successful in 19s
Check meta / check_dns (push) Successful in 20s
build configuration / build_and_cache_rescue01 (push) Successful in 1m27s
build configuration / build_and_cache_geo01 (push) Successful in 1m12s
build configuration / build_and_cache_storage01 (push) Successful in 1m30s
build configuration / build_and_cache_geo02 (push) Successful in 1m13s
build configuration / build_and_cache_compute01 (push) Successful in 1m42s
build configuration / build_and_cache_web02 (push) Has been cancelled
build configuration / build_and_cache_web01 (push) Has been cancelled
build configuration / build_and_cache_vault01 (push) Has been cancelled
build configuration / build_and_cache_bridge01 (push) Has been cancelled
build configuration / build_and_cache_krz01 (push) Has been cancelled
lint / check (push) Has been cancelled
feat(storage01): add monorepo-terraform-state.s3.dgnum.eu
This is required to bootstrap the Terranix setup.

Signed-off-by: Ryan Lahfa <ryan@dgnum.eu>
2024-10-10 17:13:11 +02:00

122 lines
2.6 KiB
Nix

{ config, pkgs, ... }:
let
host = "s3.dgnum.eu";
webHost = "cdn.dgnum.eu";
data_dir = "/data/slow/garage/data";
metadata_dir = "/data/fast/garage/meta";
domains = [
"bandarretdurgence.ens.fr"
"boussole-sante.normalesup.eu"
"lanuit.ens.fr"
"simi.normalesup.eu"
];
buckets = [
"monorepo-terraform-state"
"banda-website"
"castopod-dgnum"
"hackens-website"
"nuit-website"
"peertube-videos-dgnum"
] ++ domains;
mkHosted = host: builtins.map (b: "${b}.${host}");
in
{
services.garage = {
enable = true;
package = pkgs.garage_1_0_1;
settings = {
inherit data_dir metadata_dir;
db_engine = "lmdb";
replication_mode = "none"; # TODO: deprecated
compression_level = 7;
rpc_bind_addr = "[::]:3901";
rpc_public_addr = "127.0.0.1:3901";
s3_api = {
s3_region = "garage";
api_bind_addr = "127.0.0.1:3900";
root_domain = ".${host}";
};
s3_web = {
bind_addr = "127.0.0.1:3902";
root_domain = ".${webHost}";
index = "index.html";
};
k2v_api.api_bind_addr = "[::]:3904";
admin.api_bind_addr = "127.0.0.1:3903";
};
environmentFile = config.age.secrets."garage-environment_file".path;
};
systemd.services.garage.serviceConfig = {
User = "garage";
ReadWriteDirectories = [
data_dir
metadata_dir
];
TimeoutSec = 600;
};
users.users.garage = {
isSystemUser = true;
group = "garage";
};
users.groups.garage = { };
services.nginx.virtualHosts = {
"s3-admin.dgnum.eu" = {
enableACME = true;
forceSSL = true;
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:3902;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
'';
};
${host} = {
enableACME = true;
forceSSL = true;
serverAliases = mkHosted host buckets;
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:3900;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# Disable buffering to a temporary file.
proxy_max_temp_file_size 0;
client_max_body_size 5G;
'';
};
${webHost} = {
enableACME = true;
forceSSL = true;
serverAliases = domains ++ (mkHosted webHost buckets);
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:3902;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
'';
};
};
}