From ec61ceb84f909787246af851c1e9f391a8b0f871 Mon Sep 17 00:00:00 2001 From: Dmitriy Kholkin Date: Sat, 8 Oct 2022 04:45:07 +0300 Subject: [PATCH] test joplin-server --- profiles/servers/joplin-server.nix | 48 ++++++++++++++++++++++++++++++ profiles/servers/nginx.nix | 14 +++++++++ 2 files changed, 62 insertions(+) create mode 100644 profiles/servers/joplin-server.nix diff --git a/profiles/servers/joplin-server.nix b/profiles/servers/joplin-server.nix new file mode 100644 index 0000000..c0e882b --- /dev/null +++ b/profiles/servers/joplin-server.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: { + virtualisation.oci-containers.containers = { + joplin = { + autoStart = true; + dependsOn = [ "joplin-db" ]; + environment = { + DB_CLIENT = "pg"; + POSTGRES_DATABASE = "joplin"; + POSTGRES_USER = "test"; + POSTGRES_PASSWORD = "test"; + POSTGRES_PORT = "5432"; + POSTGRES_HOST = "joplin-db"; + APP_PORT = "22300"; + APP_BASE_URL = "joplin.ataraxiadev.com"; + }; + extraOptions = [ + "--network=joplin" + ]; + ports = [ "127.0.0.1:22300:22300" ]; + image = "joplin:latest-dev"; + }; + joplin-db = { + autoStart = true; + environment = { + POSTGRES_PASSWORD= "test"; + POSTGRES_USER = "test"; + POSTGRES_DB = "joplin"; + }; + extraOptions = [ + "--network=joplin" + ]; + image = "postgres:13"; + # volumes = [ "/server/data/postgres:/var/lib/postgresql/data" ]; + }; + }; + systemd.services.create-joplin-network = with config.virtualisation.oci-containers; { + serviceConfig.Type = "oneshot"; + wantedBy = [ + "${backend}-joplin.service" + "${backend}-joplin-db.service" + ]; + script = '' + ${pkgs.docker}/bin/docker network inspect joplin || \ + ${pkgs.docker}/bin/docker network create -d bridge joplin + exit 0 + ''; + }; +} \ No newline at end of file diff --git a/profiles/servers/nginx.nix b/profiles/servers/nginx.nix index c124a3f..fa24d25 100644 --- a/profiles/servers/nginx.nix +++ b/profiles/servers/nginx.nix @@ -35,6 +35,7 @@ "shoko.ataraxiadev.com" "bathist.ataraxiadev.com" "microbin.ataraxiadev.com" + # "joplin.ataraxiadev.com" ]; }; }; @@ -236,6 +237,19 @@ ''; }; } // default; + "joplin.ataraxiadev.com" = { + locations."/" = { + proxyPass = "http://localhost:22300"; + extraConfig = '' + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + ''; + }; + } // default; }; };