feat(coder): Add module
This commit is contained in:
parent
f1ba0a98e8
commit
ef55596de6
5 changed files with 142 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
$TTL 604800
|
||||
@ IN SOA ns1 admin (
|
||||
15 ; Serial
|
||||
18 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
|
|
@ -40,6 +40,9 @@ sonarr IN A 192.168.0.33
|
|||
; Development VM
|
||||
plex IN A 192.168.0.91
|
||||
|
||||
code IN A 192.168.0.91
|
||||
*.code IN A 192.168.0.91
|
||||
|
||||
; Catchalls
|
||||
*.production IN A 192.168.0.31
|
||||
*.development IN A 192.168.0.91
|
||||
|
|
|
|||
131
modules/apps/coder/default.nix
Normal file
131
modules/apps/coder/default.nix
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.homelab.apps.coder;
|
||||
|
||||
postgresUser = "coder";
|
||||
postgresPassword = "ChangeMe";
|
||||
postgresDb = "coder";
|
||||
|
||||
networkName = "coder";
|
||||
proxyNet = config.homelab.apps.traefik.sharedNetworkName;
|
||||
|
||||
coderVersion = "v2.25.3";
|
||||
coderDbVersion = "17.6";
|
||||
in {
|
||||
options.homelab.apps.coder = {
|
||||
enable = lib.mkEnableOption "Coder (Docker)";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 7080;
|
||||
description = "Port to expose Coder on.";
|
||||
};
|
||||
accessUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The URL to access Coder at.";
|
||||
};
|
||||
wildcardAccessUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "A wildcard URL to access Coder at (e.g. for workspaces).";
|
||||
};
|
||||
|
||||
db.port = lib.mkOption {
|
||||
type = lib.types.either lib.types.bool lib.types.port;
|
||||
default = false;
|
||||
description = "Port to expose the database on. Set to false to not expose.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
homelab.virtualisation.containers.enable = true;
|
||||
|
||||
systemd.services."docker-${networkName}-create-network" = {
|
||||
description = "Create Docker network for ${networkName}";
|
||||
requiredBy = [
|
||||
"docker-coder.service"
|
||||
"docker-coderDb.service"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
if ! ${pkgs.docker}/bin/docker network ls | grep -q ${networkName}; then
|
||||
${pkgs.docker}/bin/docker network create ${networkName}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers = {
|
||||
coder = let
|
||||
coderPort = 7080;
|
||||
in {
|
||||
hostname = "coder";
|
||||
image = "ghcr.io/coder/coder:${coderVersion}";
|
||||
autoStart = true;
|
||||
dependsOn = [
|
||||
"coderDb"
|
||||
];
|
||||
ports = [
|
||||
"${toString cfg.port}:${toString coderPort}/tcp"
|
||||
];
|
||||
networks = [
|
||||
networkName
|
||||
proxyNet
|
||||
];
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
];
|
||||
labels = {
|
||||
"traefik.enable" = "true";
|
||||
"traefik.docker.network" = proxyNet;
|
||||
"traefik.http.routers.coder.rule" = "Host(`code.depeuter.dev`)";
|
||||
"traefik.http.services.coder.loadbalancer.server.port" = toString coderPort;
|
||||
};
|
||||
environment = {
|
||||
CODER_PG_CONNECTION_URL = "postgresql://${postgresUser}:${postgresPassword}@database/${postgresDb}?sslmode=disable";
|
||||
|
||||
# Required if you are not using the tunnel
|
||||
CODER_ACCESS_URL = cfg.accessUrl;
|
||||
CODER_WILDCARD_ACCESS_URL = cfg.wildcardAccessUrl;
|
||||
CODER_DISABLE_PATH_APPS = "true";
|
||||
|
||||
CODER_HTTP_ADDRESS = "0.0.0.0:${toString coderPort}";
|
||||
CODER_TLS_ENABLE = "false";
|
||||
|
||||
# TODO Enable me!
|
||||
#CODER_REDIRECT_TO_ACCESS_URL = "true";
|
||||
|
||||
# Disable telemetry
|
||||
CODER_TELEMETRY_ENABLED = "false";
|
||||
};
|
||||
};
|
||||
|
||||
coderDb = {
|
||||
hostname = "coder-db";
|
||||
image = "postgres:${coderDbVersion}";
|
||||
autoStart = true;
|
||||
ports = lib.mkIf cfg.db.port [
|
||||
"${toString cfg.db.port}:5432/tcp"
|
||||
];
|
||||
networks = [
|
||||
networkName
|
||||
];
|
||||
extraOptions = [
|
||||
''--health-cmd="pg_isready -U ${postgresUser} -d ${postgresDb}"''
|
||||
"--health-interval=5s"
|
||||
"--health-timeout=5s"
|
||||
"--health-retries=5"
|
||||
];
|
||||
volumes = [
|
||||
"coder_data:/var/lib/postgresql/data"
|
||||
];
|
||||
environment = {
|
||||
POSTGRES_USER = postgresUser;
|
||||
POSTGRES_PASSWORD = postgresPassword;
|
||||
POSTGRES_DB = postgresDb;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
./bind9
|
||||
./calibre
|
||||
./changedetection
|
||||
./coder
|
||||
./freshrss
|
||||
./gitea
|
||||
./jellyfin
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ in {
|
|||
options.homelab.apps.vaultwarden = {
|
||||
enable = lib.mkEnableOption "Vaultwarden";
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
type = lib.types.port;
|
||||
default = 10102;
|
||||
description = "Vaultwarden WebUI port";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue