summaryrefslogtreecommitdiff
path: root/adonis/autopush
diff options
context:
space:
mode:
authortoufic ar <contact@toufy.me>2026-07-19 17:29:23 +0300
committertoufic ar <contact@toufy.me>2026-07-19 17:29:23 +0300
commit5bd6732c69849022894303d4ab90b8204579c0fc (patch)
treebf4903c39641600cd1468426520a0aa011b4e8a5 /adonis/autopush
parenta28939090485f476efb73b3de0ce277e19c02b96 (diff)
downloadservers-5bd6732c69849022894303d4ab90b8204579c0fc.tar.gz
servers-5bd6732c69849022894303d4ab90b8204579c0fc.zip
revert autopush, remove docker
Diffstat (limited to 'adonis/autopush')
-rw-r--r--adonis/autopush/default.nix206
1 files changed, 37 insertions, 169 deletions
diff --git a/adonis/autopush/default.nix b/adonis/autopush/default.nix
index 3679988..7e5e45c 100644
--- a/adonis/autopush/default.nix
+++ b/adonis/autopush/default.nix
@@ -1,194 +1,62 @@
{
config,
pkgs,
- lib,
...
}: let
domain = "push.${config.customOps.domain.fqdn}";
- connectPort = 8082;
- endpointPort = 8080;
+ port = 8082;
+ redisPort = 6369;
+ endpointPort = 443;
+ autopush = pkgs.autopush-rs;
in {
sops.secrets = {
"autopush/autoconnect" = {};
"autopush/autoendpoint" = {};
};
- virtualisation.oci-containers.containers."autopush-autoconnect" = {
- image = "compose2nix/autopush-autoconnect";
- environment = {
- "AUTOCONNECT__DB_DSN" = "redis://redis";
- "AUTOCONNECT__ENDPOINT_HOSTNAME" = "updates.${domain}";
- "AUTOCONNECT__ENDPOINT_PORT" = "443";
- "AUTOCONNECT__ENDPOINT_SCHEME" = "https";
- "AUTOCONNECT__ROUTER_HOSTNAME" = "autoconnect";
- };
- environmentFiles = [
- config.sops.secrets."autopush/autoconnect".path
- ];
- ports = [
- "8080:8080/tcp"
- ];
- dependsOn = [
- "autopush-redis"
- ];
- log-driver = "journald";
- extraOptions = [
- "--network-alias=autoconnect"
- "--network=autopush_default"
- ];
- };
-
- systemd.services."docker-autopush-autoconnect" = {
- serviceConfig = {
- Restart = lib.mkOverride 90 "always";
- RestartMaxDelaySec = lib.mkOverride 90 "1m";
- RestartSec = lib.mkOverride 90 "100ms";
- RestartSteps = lib.mkOverride 90 9;
- };
- after = [
- "docker-network-autopush_default.service"
- ];
- requires = [
- "docker-network-autopush_default.service"
- ];
- partOf = [
- "docker-compose-autopush-root.target"
- ];
- wantedBy = [
- "docker-compose-autopush-root.target"
- ];
- };
-
- virtualisation.oci-containers.containers."autopush-autoend" = {
- image = "compose2nix/autopush-autoend";
- environment = {
- "AUTOEND__DB_DSN" = "redis://redis";
- "AUTOEND__ENDPOINT_URL" = "https://updates.${domain}";
- "AUTOEND__HOST" = "0.0.0.0";
- "AUTOEND__PORT" = "8082";
- };
- environmentFiles = [
- config.sops.secrets."autopush/autoendpoint".path
- ];
-
- ports = [
- "8082:8082/tcp"
- ];
- dependsOn = [
- "autopush-autoconnect"
- "autopush-redis"
- ];
- log-driver = "journald";
- extraOptions = [
- "--network-alias=autoendpoint"
- "--network=autopush_default"
- ];
+ environment.systemPackages = [autopush];
+ services.redis.servers."autopush" = {
+ enable = true;
+ port = redisPort;
};
-
- systemd.services."docker-autopush-autoend" = {
- serviceConfig = {
- Restart = lib.mkOverride 90 "always";
- RestartMaxDelaySec = lib.mkOverride 90 "1m";
- RestartSec = lib.mkOverride 90 "100ms";
- RestartSteps = lib.mkOverride 90 9;
+ systemd.services = {
+ autopush-autoconnect = {
+ environment = {
+ AUTOCONNECT__DB_DSN = "redis://127.0.0.1:${builtins.toString redisPort}";
+ AUTOCONNECT__ENDPOINT_SCHEME = "https";
+ AUTOCONNECT__ENDPOINT_HOSTNAME = "updates.${domain}";
+ AUTOCONNECT__ENDPOINT_PORT = builtins.toString endpointPort;
+ AUTOCONNECT__ROUTER_HOSTNAME = "localhost";
+ };
+ wantedBy = ["multi-user.target"];
+ serviceConfig = {
+ EnvironmentFile = config.sops.secrets."autopush/autoconnect".path;
+ ExecStart = "${autopush}/bin/autoconnect";
+ };
};
- after = [
- "docker-network-autopush_default.service"
- ];
- requires = [
- "docker-network-autopush_default.service"
- ];
- partOf = [
- "docker-compose-autopush-root.target"
- ];
- wantedBy = [
- "docker-compose-autopush-root.target"
- ];
- };
-
- virtualisation.oci-containers.containers."autopush-redis" = {
- image = "redis:latest";
- cmd = ["redis-server"];
- log-driver = "journald";
- extraOptions = [
- "--network-alias=redis"
- "--network=autopush_default"
- ];
- };
-
- systemd.services."docker-autopush-redis" = {
- serviceConfig = {
- Restart = lib.mkOverride 90 "always";
- RestartMaxDelaySec = lib.mkOverride 90 "1m";
- RestartSec = lib.mkOverride 90 "100ms";
- RestartSteps = lib.mkOverride 90 9;
+ autopush-autoendpoint = {
+ environment = {
+ AUTOEND__DB_DSN = "redis://127.0.0.1:${builtins.toString redisPort}";
+ AUTOEND__HOST = "127.0.0.1";
+ AUTOEND__PORT = builtins.toString port;
+ AUTOEND__ENDPOINT_URL = "https://updates.${domain}";
+ AUTOEND__HUMAN_LOGS = "true";
+ };
+ wantedBy = ["multi-user.target"];
+ serviceConfig = {
+ EnvironmentFile = config.sops.secrets."autopush/autoendpoint".path;
+ ExecStart = "${autopush}/bin/autoendpoint";
+ };
};
- after = [
- "docker-network-autopush_default.service"
- ];
- requires = [
- "docker-network-autopush_default.service"
- ];
- partOf = [
- "docker-compose-autopush-root.target"
- ];
- wantedBy = [
- "docker-compose-autopush-root.target"
- ];
};
-
- systemd.services."docker-network-autopush_default" = {
- path = [pkgs.docker];
- serviceConfig = {
- Type = "oneshot";
- RemainAfterExit = true;
- ExecStop = "docker network rm -f autopush_default";
- };
- script = ''
- docker network inspect autopush_default || docker network create autopush_default
- '';
- partOf = ["docker-compose-autopush-root.target"];
- wantedBy = ["docker-compose-autopush-root.target"];
- };
-
- systemd.services."docker-build-autopush-autoconnect" = {
- path = [pkgs.docker pkgs.git];
- serviceConfig = {
- Type = "oneshot";
- TimeoutSec = 1200;
- };
- script = ''
- docker build -t compose2nix/autopush-autoconnect --build-arg BINARY=autoconnect --build-arg BUILD_ARGS="--no-default-features --features redis" --build-arg CRATE=autoconnect https://github.com/mozilla-services/autopush-rs.git
- '';
- };
-
- systemd.services."docker-build-autopush-autoend" = {
- path = [pkgs.docker pkgs.git];
- serviceConfig = {
- Type = "oneshot";
- TimeoutSec = 1200;
- };
- script = ''
- docker build -t compose2nix/autopush-autoend --build-arg BUILD_ARGS="--no-default-features --features redis" --build-arg CRATE=autoendpoint --build-arg BINARY=autoendpoint https://github.com/mozilla-services/autopush-rs.git
- '';
- };
-
- systemd.targets."docker-compose-autopush-root" = {
- unitConfig = {
- Description = "Root target generated by compose2nix.";
- };
- wantedBy = ["multi-user.target"];
- };
-
services.nginx.virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
- locations."/".proxyPass = "http://127.0.0.1:${builtins.toString endpointPort}";
+ locations."/".proxyPass = "http://127.0.0.1:8080";
};
-
services.nginx.virtualHosts."updates.${domain}" = {
forceSSL = true;
enableACME = true;
- locations."/".proxyPass = "http://127.0.0.1:${builtins.toString connectPort}";
+ locations."/".proxyPass = "http://127.0.0.1:${builtins.toString port}";
};
}