Add shlink

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-06-29 12:56:19 +01:00
parent d617183438
commit ea2ab2101a
11 changed files with 17579 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
{
pkgs,
inputs,
system,
...
}:
let
selfPkgs = inputs.self.packages.${system};
php = pkgs.php84.buildEnv {
extensions =
{ all, ... }:
with all;
[
curl
pdo
pdo_sqlite
pdo_pgsql
intl
gd
sockets
bcmath
filter
mbstring
zlib
];
extraConfig = ''
expose_php = Off
'';
};
shlink = pkgs.runCommandLocal "shlink" { } ''
mkdir -p $out/var/www
cp -r ${selfPkgs.shlink} $out/var/www/shlink
'';
shlink-cli = pkgs.writeShellApplication {
name = "shlink";
text = ''
exec /var/www/shlink/bin/cli "$@"
'';
};
entrypoint = pkgs.writeTextFile {
name = "entrypoint";
executable = true;
destination = "/bin/entrypoint";
text = builtins.readFile ./entrypoint.sh;
};
in
pkgs.dockerTools.buildImage {
name = "shlink";
fromImage = import ../base { inherit pkgs; };
copyToRoot = pkgs.buildEnv {
name = "root";
paths = [
entrypoint
shlink
shlink-cli
php
pkgs.roadrunner
];
pathsToLink = [
"/bin"
"/var"
];
};
config = {
Entrypoint = [ "entrypoint" ];
WorkingDir = "/var/www/shlink";
Volumes = {
"/var/www/shlink/data" = { };
};
ExposedPorts = {
"8080/tcp" = { };
};
};
}

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env sh
set -o errexit
mkdir -p \
/var/www/shlink/data/cache \
/var/www/shlink/data/locks \
/var/www/shlink/data/log \
/var/www/shlink/data/proxies
GEOLITE_LICENSE_KEY=$(/var/www/shlink/bin/cli env-var:read GEOLITE_LICENSE_KEY)
SKIP_INITIAL_GEOLITE_DOWNLOAD=$(/var/www/shlink/bin/cli env-var:read SKIP_INITIAL_GEOLITE_DOWNLOAD)
INITIAL_API_KEY=$(/var/www/shlink/bin/cli env-var:read INITIAL_API_KEY)
init_flags="--no-interaction --clear-db-cache"
if [ -z "${GEOLITE_LICENSE_KEY}" ] || [ "${SKIP_INITIAL_GEOLITE_DOWNLOAD}" = "true" ]; then
init_flags="${init_flags} --skip-download-geolite"
fi
if [ -n "${INITIAL_API_KEY}" ]; then
init_flags="${init_flags} --initial-api-key=${INITIAL_API_KEY}"
fi
# shellcheck disable=SC2086
php /var/www/shlink/vendor/bin/shlink-installer init ${init_flags}
exec rr serve -c /var/www/shlink/config/roadrunner/.rr.yml "$@"