feat(installer): add --registry, --registry-user, --registry-token
All checks were successful
CI / build (push) Successful in 1m21s
CI / docker (push) Successful in 15s

Both installers (bash + PS1) now support pulling images from a
custom Docker registry. Writes *_IMAGE env vars to .env so compose
templates use the configured registry. Runs docker login before
pull when credentials are provided. Persisted in cameleer.conf
for upgrades/reconfigure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-25 02:10:48 +02:00
parent 180644f0df
commit e1a9f6d225
3 changed files with 117 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ set -euo pipefail
CAMELEER_INSTALLER_VERSION="1.0.0"
CAMELEER_DEFAULT_VERSION="latest"
REGISTRY="gitea.siegeln.net/cameleer"
DEFAULT_REGISTRY="gitea.siegeln.net/cameleer"
# --- Colors ---
RED='\033[0;31m'
@@ -51,6 +51,9 @@ _ENV_SMTP_PORT="${SMTP_PORT:-}"
_ENV_SMTP_USER="${SMTP_USER:-}"
_ENV_SMTP_PASS="${SMTP_PASS:-}"
_ENV_SMTP_FROM_EMAIL="${SMTP_FROM_EMAIL:-}"
_ENV_REGISTRY="${REGISTRY:-}"
_ENV_REGISTRY_USER="${REGISTRY_USER:-}"
_ENV_REGISTRY_TOKEN="${REGISTRY_TOKEN:-}"
INSTALL_DIR=""
PUBLIC_HOST=""
@@ -79,6 +82,9 @@ SMTP_PORT=""
SMTP_USER=""
SMTP_PASS=""
SMTP_FROM_EMAIL=""
REGISTRY=""
REGISTRY_USER=""
REGISTRY_TOKEN=""
# --- State ---
MODE="" # simple, expert, silent
@@ -185,6 +191,9 @@ parse_args() {
--smtp-user) SMTP_USER="$2"; shift ;;
--smtp-pass) SMTP_PASS="$2"; shift ;;
--smtp-from-email) SMTP_FROM_EMAIL="$2"; shift ;;
--registry) REGISTRY="$2"; shift ;;
--registry-user) REGISTRY_USER="$2"; shift ;;
--registry-token) REGISTRY_TOKEN="$2"; shift ;;
--server-admin-user) ADMIN_USER="$2"; shift ;;
--server-admin-password) ADMIN_PASS="$2"; shift ;;
--reconfigure) RERUN_ACTION="reconfigure" ;;
@@ -224,6 +233,11 @@ show_help() {
echo " --config FILE Load config from file"
echo " --help Show this help"
echo ""
echo "Registry options:"
echo " --registry REGISTRY Image registry (default: gitea.siegeln.net/cameleer)"
echo " --registry-user USER Registry username for docker login"
echo " --registry-token TOKEN Registry token/password for docker login"
echo ""
echo "Expert options:"
echo " --postgres-password, --clickhouse-password, --http-port,"
echo " --https-port, --logto-console-port, --logto-console-exposed,"
@@ -275,6 +289,9 @@ load_config_file() {
smtp_user) [ -z "$SMTP_USER" ] && SMTP_USER="$value" ;;
smtp_pass) [ -z "$SMTP_PASS" ] && SMTP_PASS="$value" ;;
smtp_from_email) [ -z "$SMTP_FROM_EMAIL" ] && SMTP_FROM_EMAIL="$value" ;;
registry) [ -z "$REGISTRY" ] && REGISTRY="$value" ;;
registry_user) [ -z "$REGISTRY_USER" ] && REGISTRY_USER="$value" ;;
registry_token) [ -z "$REGISTRY_TOKEN" ] && REGISTRY_TOKEN="$value" ;;
esac
done < "$file"
}
@@ -307,6 +324,9 @@ load_env_overrides() {
[ -z "$SMTP_USER" ] && SMTP_USER="$_ENV_SMTP_USER"
[ -z "$SMTP_PASS" ] && SMTP_PASS="$_ENV_SMTP_PASS"
[ -z "$SMTP_FROM_EMAIL" ] && SMTP_FROM_EMAIL="$_ENV_SMTP_FROM_EMAIL"
[ -z "$REGISTRY" ] && REGISTRY="$_ENV_REGISTRY"
[ -z "$REGISTRY_USER" ] && REGISTRY_USER="$_ENV_REGISTRY_USER"
[ -z "$REGISTRY_TOKEN" ] && REGISTRY_TOKEN="$_ENV_REGISTRY_TOKEN"
}
# --- Prerequisites ---
@@ -530,6 +550,7 @@ merge_config() {
: "${LOGTO_CONSOLE_EXPOSED:=$DEFAULT_LOGTO_CONSOLE_EXPOSED}"
: "${VERSION:=$CAMELEER_DEFAULT_VERSION}"
: "${DOCKER_SOCKET:=$DEFAULT_DOCKER_SOCKET}"
: "${REGISTRY:=$DEFAULT_REGISTRY}"
if [ "$DEPLOYMENT_MODE" = "standalone" ]; then
: "${COMPOSE_PROJECT:=$DEFAULT_COMPOSE_PROJECT_STANDALONE}"
@@ -657,6 +678,12 @@ DOCKER_GID=$(stat -c '%g' "${DOCKER_SOCKET}" 2>/dev/null || echo "0")
POSTGRES_IMAGE=postgres:16-alpine
# Registry
TRAEFIK_IMAGE=${REGISTRY}/cameleer-traefik
CLICKHOUSE_IMAGE=${REGISTRY}/cameleer-clickhouse
SERVER_IMAGE=${REGISTRY}/cameleer-server
SERVER_UI_IMAGE=${REGISTRY}/cameleer-server-ui
# Compose file assembly
COMPOSE_FILE=docker-compose.yml:docker-compose.server.yml$([ "$TLS_MODE" = "custom" ] && echo ":docker-compose.tls.yml")$([ -n "$MONITORING_NETWORK" ] && echo ":docker-compose.monitoring.yml")
EOF
@@ -725,6 +752,13 @@ EOF
DOCKER_SOCKET=${DOCKER_SOCKET}
DOCKER_GID=$(stat -c '%g' "${DOCKER_SOCKET}" 2>/dev/null || echo "0")
# Registry
TRAEFIK_IMAGE=${REGISTRY}/cameleer-traefik
POSTGRES_IMAGE=${REGISTRY}/cameleer-postgres
CLICKHOUSE_IMAGE=${REGISTRY}/cameleer-clickhouse
LOGTO_IMAGE=${REGISTRY}/cameleer-logto
CAMELEER_IMAGE=${REGISTRY}/cameleer-saas
# Provisioning images
CAMELEER_SAAS_PROVISIONING_SERVERIMAGE=${REGISTRY}/cameleer-server:${VERSION}
CAMELEER_SAAS_PROVISIONING_SERVERUIIMAGE=${REGISTRY}/cameleer-server-ui:${VERSION}
@@ -783,6 +817,16 @@ copy_templates() {
# --- Docker operations ---
docker_registry_login() {
if [ -n "$REGISTRY_USER" ] && [ -n "$REGISTRY_TOKEN" ]; then
local registry_host
registry_host=$(echo "$REGISTRY" | cut -d/ -f1)
log_info "Logging in to registry ${registry_host}..."
echo "$REGISTRY_TOKEN" | docker login "$registry_host" -u "$REGISTRY_USER" --password-stdin
log_success "Registry login successful."
fi
}
docker_compose_pull() {
log_info "Pulling Docker images..."
(cd "$INSTALL_DIR" && docker compose -p "$COMPOSE_PROJECT" pull)
@@ -916,6 +960,9 @@ smtp_port=${SMTP_PORT}
smtp_user=${SMTP_USER}
smtp_pass=${SMTP_PASS}
smtp_from_email=${SMTP_FROM_EMAIL}
registry=${REGISTRY}
registry_user=${REGISTRY_USER}
registry_token=${REGISTRY_TOKEN}
EOF
log_info "Saved installer config to cameleer.conf"
}
@@ -1354,6 +1401,7 @@ handle_rerun() {
load_env_overrides
merge_config
copy_templates
docker_registry_login
docker_compose_pull
docker_compose_down
docker_compose_up
@@ -1448,6 +1496,7 @@ main() {
write_config_file
# Pull and start
docker_registry_login
docker_compose_pull
docker_compose_up