@@ -17,6 +17,8 @@
|
||||
docker-image-grafana-image-renderer = import ./docker/grafana-image-renderer { inherit pkgs; };
|
||||
docker-image-grafana-to-ntfy = import ./docker/grafana-to-ntfy { inherit pkgs; };
|
||||
docker-image-grafana = import ./docker/grafana { inherit pkgs; };
|
||||
docker-image-immich = import ./docker/immich { inherit pkgs; };
|
||||
docker-image-immich-machine-learning = import ./docker/immich-machine-learning { inherit pkgs; };
|
||||
docker-image-jellyseerr = import ./docker/jellyseerr { inherit pkgs; };
|
||||
docker-image-littlelink-server = import ./docker/littlelink-server { inherit pkgs; };
|
||||
docker-image-mariadb = import ./docker/mariadb { inherit pkgs; };
|
||||
@@ -29,6 +31,7 @@
|
||||
docker-image-outline = import ./docker/outline { inherit pkgs; };
|
||||
docker-image-plex = import ./docker/plex { inherit pkgs; };
|
||||
docker-image-postgresql = import ./docker/postgresql { inherit pkgs; };
|
||||
docker-image-postgresql-vectorchord = import ./docker/postgresql-vectorchord { inherit pkgs; };
|
||||
docker-image-prometheus = import ./docker/prometheus { inherit pkgs; };
|
||||
docker-image-prometheus-fail2ban-exporter = import ./docker/prometheus-fail2ban-exporter {
|
||||
inherit pkgs;
|
||||
|
41
packages/docker/immich-machine-learning/default.nix
Normal file
41
packages/docker/immich-machine-learning/default.nix
Normal file
@@ -0,0 +1,41 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
entrypoint = pkgs.writeTextFile {
|
||||
name = "entrypoint";
|
||||
executable = true;
|
||||
destination = "/bin/entrypoint";
|
||||
text = builtins.readFile ./entrypoint.sh;
|
||||
};
|
||||
in
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "immich-machine-learning";
|
||||
fromImage = pkgs.docker-image-base;
|
||||
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "root";
|
||||
paths = with pkgs; [
|
||||
entrypoint
|
||||
immich-machine-learning
|
||||
];
|
||||
pathsToLink = [
|
||||
"/bin"
|
||||
"/lib"
|
||||
"/share"
|
||||
"/nix-support"
|
||||
];
|
||||
};
|
||||
|
||||
config = {
|
||||
Entrypoint = [ "entrypoint" ];
|
||||
Volumes = {
|
||||
"/tmp/immich-machine-learning" = { };
|
||||
};
|
||||
Env = [
|
||||
"IMMICH_LOG_LEVEL=warn"
|
||||
"MACHINE_LEARNING_CACHE_FOLDER=/tmp/immich-machine-learning"
|
||||
];
|
||||
ExposedPorts = {
|
||||
"3003/tcp" = { };
|
||||
};
|
||||
};
|
||||
}
|
19
packages/docker/immich-machine-learning/entrypoint.sh
Normal file
19
packages/docker/immich-machine-learning/entrypoint.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
LOG_PIPE="$(mktemp -u)"
|
||||
mkfifo "$LOG_PIPE"
|
||||
|
||||
(
|
||||
while IFS= read -r line; do
|
||||
if echo "$line" | grep -qEi "\[(WARN|ERROR)\]"; then
|
||||
echo "$line" >&2
|
||||
else
|
||||
echo "$line"
|
||||
fi
|
||||
done < "$LOG_PIPE"
|
||||
) &
|
||||
|
||||
exec machine-learning "$@" > "$LOG_PIPE" 2>&1
|
42
packages/docker/immich/default.nix
Normal file
42
packages/docker/immich/default.nix
Normal file
@@ -0,0 +1,42 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
entrypoint = pkgs.writeTextFile {
|
||||
name = "entrypoint";
|
||||
executable = true;
|
||||
destination = "/bin/entrypoint";
|
||||
text = builtins.readFile ./entrypoint.sh;
|
||||
};
|
||||
in
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "immich";
|
||||
fromImage = pkgs.docker-image-base;
|
||||
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "root";
|
||||
paths = with pkgs; [
|
||||
entrypoint
|
||||
immich
|
||||
curl
|
||||
jq
|
||||
];
|
||||
pathsToLink = [
|
||||
"/bin"
|
||||
"/lib"
|
||||
];
|
||||
};
|
||||
|
||||
config = {
|
||||
Entrypoint = [ "entrypoint" ];
|
||||
Volumes = {
|
||||
"/var/lib/immich" = { };
|
||||
};
|
||||
WorkingDir = "/var/lib/immich";
|
||||
Env = [
|
||||
"IMMICH_CONFIG_FILE=/etc/immich/config.json"
|
||||
"IMMICH_MEDIA_LOCATION=/var/lib/immich"
|
||||
];
|
||||
ExposedPorts = {
|
||||
"2283/tcp" = { };
|
||||
};
|
||||
};
|
||||
}
|
16
packages/docker/immich/entrypoint.sh
Normal file
16
packages/docker/immich/entrypoint.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
server "$@" &
|
||||
PID="$!"
|
||||
|
||||
if [ -f /etc/immich/post-start.sh ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/immich/post-start.sh
|
||||
fi
|
||||
|
||||
trap 'kill -KILL "$PID"' INT TERM
|
||||
wait "$PID"
|
||||
exit $?
|
100
packages/docker/postgresql-vectorchord/default.nix
Normal file
100
packages/docker/postgresql-vectorchord/default.nix
Normal file
@@ -0,0 +1,100 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
postgresql = pkgs.postgresql.overrideAttrs (oldAttrs: {
|
||||
patches = oldAttrs.patches or [ ] ++ [ ../postgresql/allow-root.patch ];
|
||||
});
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/sql/postgresql/generic.nix
|
||||
postgresqlVectorchord =
|
||||
let
|
||||
installedExtensions = with postgresql.pkgs; [
|
||||
pgvector
|
||||
vectorchord
|
||||
];
|
||||
|
||||
finalPackage = pkgs.buildEnv {
|
||||
name = "${postgresql.pname}-vectorchord";
|
||||
|
||||
paths = installedExtensions ++ [
|
||||
postgresql
|
||||
postgresql.man
|
||||
];
|
||||
|
||||
pathsToLink = [
|
||||
"/"
|
||||
"/bin"
|
||||
"/share/postgresql/extension"
|
||||
"/share/postgresql/timezonesets"
|
||||
"/share/postgresql/tsearch_data"
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; [ makeBinaryWrapper ];
|
||||
|
||||
postBuild =
|
||||
let
|
||||
args = pkgs.lib.concatMap (ext: ext.wrapperArgs or [ ]) installedExtensions;
|
||||
in
|
||||
''
|
||||
wrapProgram "$out/bin/postgres" ${pkgs.lib.concatStringsSep " " args}
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit installedExtensions;
|
||||
inherit (postgresql) pkgs psqlSchema version;
|
||||
|
||||
pg_config = postgresql.pg_config.override {
|
||||
outputs = {
|
||||
out = finalPackage;
|
||||
man = finalPackage;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
finalPackage;
|
||||
|
||||
entrypoint = pkgs.writeTextFile {
|
||||
name = "entrypoint";
|
||||
executable = true;
|
||||
destination = "/bin/entrypoint";
|
||||
text = builtins.readFile ../postgresql/entrypoint.sh;
|
||||
};
|
||||
|
||||
init = pkgs.writeTextDir "/etc/postgresql/init.sh" (builtins.readFile ./init.sh);
|
||||
in
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "postgresql-vectorchord";
|
||||
fromImage = pkgs.docker-image-base;
|
||||
|
||||
copyToRoot = pkgs.buildEnv {
|
||||
name = "root";
|
||||
paths = [
|
||||
entrypoint
|
||||
postgresqlVectorchord
|
||||
init
|
||||
];
|
||||
pathsToLink = [
|
||||
"/bin"
|
||||
"/lib"
|
||||
"/share"
|
||||
];
|
||||
};
|
||||
|
||||
runAsRoot = ''
|
||||
mkdir -p /etc/postgresql /run/postgresql
|
||||
cp ${postgresql}/share/postgresql/postgresql.conf.sample /etc/postgresql/postgresql.conf
|
||||
${pkgs.gnused}/bin/sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /etc/postgresql/postgresql.conf
|
||||
${pkgs.gnused}/bin/sed -ri "s/^#shared_preload_libraries = '''/shared_preload_libraries = 'vchord'/" /etc/postgresql/postgresql.conf
|
||||
'';
|
||||
|
||||
config = {
|
||||
Entrypoint = [ "entrypoint" ];
|
||||
ExposedPorts = {
|
||||
"5432/tcp" = { };
|
||||
};
|
||||
WorkingDir = "/var/lib/postgresql";
|
||||
Volumes = {
|
||||
"/var/lib/postgresql/data" = { };
|
||||
};
|
||||
};
|
||||
}
|
3
packages/docker/postgresql-vectorchord/init.sh
Normal file
3
packages/docker/postgresql-vectorchord/init.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
# shellcheck shell=sh
|
||||
|
||||
psql --username="$POSTGRES_USER" -d postgres -c "CREATE EXTENSION IF NOT EXISTS vchord CASCADE;"
|
@@ -31,13 +31,18 @@ if [ ! -s "$PGDATA/PG_VERSION" ]; then
|
||||
POSTGRES_HOST_AUTH_METHOD="${POSTGRES_HOST_AUTH_METHOD:=$auth_method}"
|
||||
printf "\nhost all all all %s\n" "$POSTGRES_HOST_AUTH_METHOD" >> "$PGDATA/pg_hba.conf"
|
||||
|
||||
pg_ctl -w start
|
||||
pg_ctl -w start -o "-c config_file=/etc/postgresql/postgresql.conf"
|
||||
|
||||
if ! psql --username="$POSTGRES_USER" -d postgres -tc "SELECT 1 FROM pg_database WHERE datname = '$POSTGRES_DB'" | grep -q 1; then
|
||||
psql --username="$POSTGRES_USER" -d postgres -c "CREATE DATABASE \"$POSTGRES_DB\";"
|
||||
fi
|
||||
|
||||
pg_ctl -m fast -w stop
|
||||
if [ -f /etc/postgresql/init.sh ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/postgresql/init.sh
|
||||
fi
|
||||
|
||||
pg_ctl -m fast -w stop -o "-c config_file=/etc/postgresql/postgresql.conf"
|
||||
fi
|
||||
|
||||
exec postgres -c config_file="/etc/postgresql/postgresql.conf" "$@" > "$LOG_PIPE" 2>&1
|
||||
|
Reference in New Issue
Block a user