From f14f15f2a23ccc578dcfedc4c2d00da24001e435 Mon Sep 17 00:00:00 2001 From: Cesar Jhoanny Mendivil Rubio Date: Wed, 1 Oct 2025 15:13:53 -0700 Subject: [PATCH] chore(easypanel): make docker-compose.easypanel env-driven + add config generator script --- README.easypanel.md | 34 +++++++++++++++++++++ docker-compose.easypanel.yml | 47 +++++++++++++++++++++++------ tools/easypanel-config-generator.sh | 40 ++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 tools/easypanel-config-generator.sh diff --git a/README.easypanel.md b/README.easypanel.md index 39428f3aa..190d5ed38 100644 --- a/README.easypanel.md +++ b/README.easypanel.md @@ -1,3 +1,37 @@ +README - EasyPanel / Git repo setup + +Este archivo describe cómo usar `docker-compose.easypanel.yml` desde EasyPanel. + +Principio: No almacenar secretos en el repositorio. EasyPanel debe inyectar los valores +mediante variables de entorno o secrets en el formulario del panel. + +Variables (mínimas recomendadas) +- POSTGRES_HOST (por defecto: postgres) +- POSTGRES_PORT (por defecto: 5432) +- POSTGRES_DB (por defecto: libretime) +- POSTGRES_USER (por defecto: libretime) +- POSTGRES_PASSWORD (REQUIRED) +- RABBITMQ_HOST (por defecto: rabbitmq) +- RABBITMQ_PORT (por defecto: 5672) +- RABBITMQ_DEFAULT_VHOST (por defecto: /libretime) +- RABBITMQ_DEFAULT_USER (por defecto: libretime) +- RABBITMQ_DEFAULT_PASS (REQUIRED) +- ICECAST_SOURCE_PASSWORD (opcional) +- ICECAST_ADMIN_PASSWORD (opcional) +- LIBRETIME_GENERAL_PUBLIC_URL (opcional) +- LIBRETIME_API_KEY (opcional) + +Cómo funciona +- Al crear la aplicación en EasyPanel, configure estas variables como "Environment Variables" o "Secrets". +- El servicio `config-generator` ejecuta `tools/easypanel-config-generator.sh` y escribe + la configuración final en el volumen `libretime_config` en `/config/config.yml`. +- Los contenedores `api`, `legacy`, `playout`, `worker` y `analyzer` montan ese volumen + en `/etc/libretime` y leen la configuración desde `/etc/libretime/config.yml`. + +Notas +- Asegúrese de que las variables sensibles (POSTGRES_PASSWORD, RABBITMQ_DEFAULT_PASS) se guarden + como secretos en EasyPanel y no como variables visibles en el repo. +- Si desea personalizar más opciones, modifique `tools/easypanel-config-generator.sh`. # LibreTime para EasyPanel Esta guía te ayudará a desplegar LibreTime en EasyPanel usando Docker Compose. diff --git a/docker-compose.easypanel.yml b/docker-compose.easypanel.yml index 34f4800c3..d256d8c68 100644 --- a/docker-compose.easypanel.yml +++ b/docker-compose.easypanel.yml @@ -1,6 +1,13 @@ -# LibreTime Docker Compose para EasyPanel -# Basado en el docker-compose oficial de LibreTime -# Optimizado para despliegue en EasyPanel +version: "3.9" + +# LibreTime Docker Compose (EasyPanel-ready) +# Esta versión está pensada para usarse desde un repositorio en EasyPanel. +# Principios: +# - No almacenar secretos en archivos del repo: EasyPanel proporcionará los valores +# mediante variables/secretos de entorno. +# - Un servicio `config-generator` genera `/config/config.yml` dentro del volumen +# `libretime_config` a partir de variables de entorno. Los servicios montan ese +# volumen en `/etc/libretime`. services: # Base de datos PostgreSQL @@ -26,7 +33,7 @@ services: environment: RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_DEFAULT_VHOST:-/libretime} RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER:-libretime} - RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-libretime} + RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS} healthcheck: test: ["CMD-SHELL", "rabbitmq-diagnostics check_port_connectivity"] interval: 30s @@ -45,11 +52,13 @@ services: condition: service_healthy rabbitmq: condition: service_healthy + config-generator: + condition: service_healthy environment: LIBRETIME_GENERAL_PUBLIC_URL: ${LIBRETIME_GENERAL_PUBLIC_URL:-http://localhost:8080} LIBRETIME_DEBUG: ${LIBRETIME_DEBUG:-false} volumes: - - ${LIBRETIME_CONFIG_FILEPATH:-./config.local.yml}:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_storage:/srv/libretime # Aplicación Legacy de LibreTime @@ -64,8 +73,10 @@ services: condition: service_healthy rabbitmq: condition: service_healthy + config-generator: + condition: service_healthy volumes: - - ${LIBRETIME_CONFIG_FILEPATH:-./config.local.yml}:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_storage:/srv/libretime # Servidor web Nginx @@ -107,7 +118,7 @@ services: rabbitmq: condition: service_healthy volumes: - - ${LIBRETIME_CONFIG_FILEPATH:-./config.local.yml}:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_playout:/app environment: LIBRETIME_GENERAL_PUBLIC_URL: ${LIBRETIME_GENERAL_PUBLIC_URL:-http://localhost:8080} @@ -127,7 +138,7 @@ services: - "${LIQUIDSOAP_HARBOR_PORT:-8001}:8001" - "${LIQUIDSOAP_TELNET_PORT:-8002}:8002" volumes: - - ${LIBRETIME_CONFIG_FILEPATH:-./config.local.yml}:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_playout:/app environment: LIBRETIME_GENERAL_PUBLIC_URL: ${LIBRETIME_GENERAL_PUBLIC_URL:-http://localhost:8080} @@ -143,7 +154,7 @@ services: rabbitmq: condition: service_healthy volumes: - - ./config.local.yml:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_storage:/srv/libretime environment: LIBRETIME_GENERAL_PUBLIC_URL: ${LIBRETIME_GENERAL_PUBLIC_URL:-http://localhost:8080} @@ -159,11 +170,25 @@ services: rabbitmq: condition: service_healthy volumes: - - ./config.local.yml:/etc/libretime/config.yml:ro + - libretime_config:/etc/libretime:ro - libretime_storage:/srv/libretime # (No se incluye servicio composer; seguir método Docker estándar de LibreTime) + # Generador de configuración (escrito por el panel desde variables/secretos) + config-generator: + image: alpine:3.18 + restart: "no" + entrypoint: ["/bin/sh","/tools/easypanel-config-generator.sh"] + volumes: + - libretime_config:/config + - ./tools:/tools:ro + healthcheck: + test: ["CMD-SHELL","test -f /config/config.yml"] + interval: 2s + timeout: 2s + retries: 10 + # Volúmenes persistentes volumes: postgres_data: @@ -172,6 +197,8 @@ volumes: driver: local libretime_playout: driver: local + libretime_config: + driver: local # Red personalizada (opcional para EasyPanel) networks: diff --git a/tools/easypanel-config-generator.sh b/tools/easypanel-config-generator.sh new file mode 100644 index 000000000..fe9694e68 --- /dev/null +++ b/tools/easypanel-config-generator.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Generador de config para EasyPanel +# Lee variables de entorno y escribe /config/config.yml + +set -eu + +CONFIG_PATH=/config/config.yml + +cat > "$CONFIG_PATH" <<'EOF' +general: + public_url: "${LIBRETIME_GENERAL_PUBLIC_URL:-http://localhost:8080}" + api_key: "${LIBRETIME_API_KEY:-}" + secret_key: "${LIBRETIME_SECRET_KEY:-}" + +database: + host: ${POSTGRES_HOST:-postgres} + port: ${POSTGRES_PORT:-5432} + name: ${POSTGRES_DB:-libretime} + user: ${POSTGRES_USER:-libretime} + password: "${POSTGRES_PASSWORD}" + +rabbitmq: + host: ${RABBITMQ_HOST:-rabbitmq} + port: ${RABBITMQ_PORT:-5672} + vhost: ${RABBITMQ_DEFAULT_VHOST:-/libretime} + user: ${RABBITMQ_DEFAULT_USER:-libretime} + password: "${RABBITMQ_DEFAULT_PASS}" + +icecast: + source_password: "${ICECAST_SOURCE_PASSWORD:-changeme}" + admin_password: "${ICECAST_ADMIN_PASSWORD:-changeme}" + relay_password: "${ICECAST_RELAY_PASSWORD:-changeme}" + admin_user: "${ICECAST_ADMIN_USER:-admin}" + hostname: "${ICECAST_HOSTNAME:-localhost}" +EOF + +echo "wrote $CONFIG_PATH" + +# Mantener el contenedor en ejecución para que dependientes puedan verificar salud +tail -f /dev/null