From 5a8e8d298dffef38ca38defa1c7e0f94092e45f7 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Fri, 21 Apr 2023 18:35:01 +0200 Subject: [PATCH] docs: docker config template install with envsubst (#2517) --- docker/config.template.yml | 279 ++++++++++++++++++ .../install/install-using-docker.md | 69 +++-- tools/update-config-files.sh | 13 + 3 files changed, 336 insertions(+), 25 deletions(-) create mode 100644 docker/config.template.yml diff --git a/docker/config.template.yml b/docker/config.template.yml new file mode 100644 index 000000000..5948a6824 --- /dev/null +++ b/docker/config.template.yml @@ -0,0 +1,279 @@ +# See https://libretime.org/docs/admin-manual/setup/configuration/ + +general: + # The public url. + # > this field is REQUIRED + public_url: + # The internal API authentication key. + # > this field is REQUIRED + api_key: + # The Django API secret key. If not defined, the value of [general.api_key] will be + # used as fallback. + # > this field will be REQUIRED starting with LibreTime 4.0.0 + secret_key: + + # List of origins allowed to access resources on the server, the public url + # origin is automatically included. + # > default is [] + allowed_cors_origins: [] + + # The server timezone, should be a lookup key in the IANA time zone database, + # for example Europe/Berlin. + # > default is UTC + timezone: UTC + + # How many hours ahead Playout should cache scheduled media files. + # > default is 1 + cache_ahead_hours: 1 + + # Authentication adaptor to use for the legacy service, specify a class like + # LibreTime_Auth_Adaptor_FreeIpa to replace the built-in adaptor. + # > default is local + auth: local + +storage: + # Path of the storage directory. + # > default is /srv/libretime + path: /srv/libretime + +database: + # The hostname of the PostgreSQL server. + # > default is localhost + host: postgres + # The port of the PostgreSQL server. + # > default is 5432 + port: 5432 + # The name of the PostgreSQL database. + # > default is libretime + name: libretime + # The username of the PostgreSQL user. + # > default is libretime + user: libretime + # The password of the PostgreSQL user. + # > default is libretime + password: ${POSTGRES_PASSWORD} + +rabbitmq: + # The hostname of the RabbitMQ server. + # > default is localhost + host: rabbitmq + # The port of the RabbitMQ server. + # > default is 5672 + port: 5672 + # The virtual host of RabbitMQ server. + # > default is /libretime + vhost: /libretime + # The username of the RabbitMQ user. + # > default is libretime + user: libretime + # The password of the RabbitMQ user. + # > default is libretime + password: ${RABBITMQ_DEFAULT_PASS} + +playout: + # Liquidsoap connection host. + # > default is localhost + liquidsoap_host: liquidsoap + # Liquidsoap connection port. + # > default is 1234 + liquidsoap_port: 1234 + + # The format for recordings. + # > must be one of (ogg, mp3) + # > default is ogg + record_file_format: ogg + # The bitrate for recordings. + # > default is 256 + record_bitrate: 256 + # The samplerate for recordings. + # > default is 44100 + record_samplerate: 44100 + # The number of channels for recordings. + # > default is 2 + record_channels: 2 + # The sample size for recordings. + # > default is 16 + record_sample_size: 16 + +liquidsoap: + # Liquidsoap server listen address. + # > default is 127.0.0.1 + server_listen_address: 0.0.0.0 + # Liquidsoap server listen port. + # > default is 1234 + server_listen_port: 1234 + + # Input harbor listen address. + # > default is ["0.0.0.0"] + harbor_listen_address: ["0.0.0.0"] + +stream: + # Inputs sources. + inputs: + # Main harbor input. + main: + # Harbor input public url. If not defined, the value will be generated from + # the [general.public_url] hostname, the input port and mount. + public_url: + # Mount point for the main harbor input. + # > default is main + mount: main + # Listen port for the main harbor input. + # > default is 8001 + port: 8001 + + # Show harbor input. + show: + # Harbor input public url. If not defined, the value will be generated from + # the [general.public_url] hostname, the input port and mount. + public_url: + # Mount point for the show harbor input. + # > default is show + mount: show + # Listen port for the show harbor input. + # > default is 8002 + port: 8002 + + # Output streams. + outputs: + # Default icecast output + # This can be reused to define multiple outputs without duplicating data + .default_icecast_output: &default_icecast_output + host: icecast + port: 8000 + source_password: ${ICECAST_SOURCE_PASSWORD} + admin_password: ${ICECAST_ADMIN_PASSWORD} + name: LibreTime! + description: LibreTime Radio! + website: https://libretime.org + genre: various + + # Icecast output streams. + # > max items is 3 + icecast: + # The default Icecast output stream + - <<: *default_icecast_output + enabled: true + public_url: + mount: main + audio: + format: ogg + bitrate: 256 + + # You can define extra outputs by reusing the default output using a yaml anchor + - <<: *default_icecast_output + enabled: false + mount: main-low + audio: + format: ogg + bitrate: 128 + + - # Whether the output is enabled. + # > default is false + enabled: false + # Output public url, If not defined, the value will be generated from + # the [general.public_url] hostname, the output port and mount. + public_url: + # Icecast server host. + # > default is localhost + host: localhost + # Icecast server port. + # > default is 8000 + port: 8000 + # Icecast server mount point. + # > this field is REQUIRED + mount: main + # Icecast source user. + # > default is source + source_user: source + # Icecast source password. + # > this field is REQUIRED + source_password: hackme + # Icecast admin user. + # > default is admin + admin_user: admin + # Icecast admin password. If not defined, statistics will not be collected. + admin_password: hackme + + # Icecast output audio. + audio: + # Icecast output audio format. + # > must be one of (aac, mp3, ogg, opus) + # > this field is REQUIRED + format: ogg + # Icecast output audio bitrate. + # > must be one of (32, 48, 64, 96, 128, 160, 192, 224, 256, 320) + # > this field is REQUIRED + bitrate: 256 + + # format=ogg only field: Embed metadata (track title, artist, and show name) + # in the output stream. Some bugged players will disconnect from the stream + # after every songs when playing ogg streams that have metadata information + # enabled. + # > default is false + enable_metadata: false + + # Icecast stream name. + name: LibreTime! + # Icecast stream description. + description: LibreTime Radio! + # Icecast stream website. + website: https://libretime.org + # Icecast stream genre. + genre: various + + # Shoutcast output streams. + # > max items is 1 + shoutcast: + - # Whether the output is enabled. + # > default is false + enabled: false + # Output public url. If not defined, the value will be generated from + # the [general.public_url] hostname and the output port. + public_url: + # Shoutcast server host. + # > default is localhost + host: localhost + # Shoutcast server port. + # > default is 8000 + port: 8000 + # Shoutcast source user. + # > default is source + source_user: source + # Shoutcast source password. + # > this field is REQUIRED + source_password: hackme + # Shoutcast admin user. + # > default is admin + admin_user: admin + # Shoutcast admin password. If not defined, statistics will not be collected. + admin_password: hackme + + # Shoutcast output audio. + audio: + # Shoutcast output audio format. + # > must be one of (aac, mp3) + # > this field is REQUIRED + format: mp3 + # Shoutcast output audio bitrate. + # > must be one of (32, 48, 64, 96, 128, 160, 192, 224, 256, 320) + # > this field is REQUIRED + bitrate: 256 + + # Shoutcast stream name. + name: LibreTime! + # Shoutcast stream website. + website: https://libretime.org + # Shoutcast stream genre. + genre: various + + # System outputs. + # > max items is 1 + system: + - # Whether the output is enabled. + # > default is false + enabled: false + # System output kind. + # > must be one of (alsa, ao, oss, portaudio, pulseaudio) + # > default is alsa + kind: alsa diff --git a/docs/admin-manual/install/install-using-docker.md b/docs/admin-manual/install/install-using-docker.md index 4f65d6d20..c4f47b6ef 100644 --- a/docs/admin-manual/install/install-using-docker.md +++ b/docs/admin-manual/install/install-using-docker.md @@ -30,9 +30,34 @@ source .env wget "https://raw.githubusercontent.com/libretime/libretime/$LIBRETIME_VERSION/docker-compose.yml" wget "https://raw.githubusercontent.com/libretime/libretime/$LIBRETIME_VERSION/docker/nginx.conf" -wget "https://raw.githubusercontent.com/libretime/libretime/$LIBRETIME_VERSION/docker/config.yml" +wget "https://raw.githubusercontent.com/libretime/libretime/$LIBRETIME_VERSION/docker/config.template.yml" ``` +:::info + +The `config.template.yml` configuration file you downloaded already contains specific values required by the container setup, you shouldn't change them: + +```yaml +database: + host: "postgres" + password: ${POSTGRES_PASSWORD} # The value will be substituted +rabbitmq: + host: "rabbitmq" + password: ${RABBITMQ_DEFAULT_PASS} # The value will be substituted +playout: + liquidsoap_host: "liquidsoap" +liquidsoap: + server_listen_address: "0.0.0.0" +stream: + outputs: + .default_icecast_output: + host: "icecast" + source_password: ${ICECAST_SOURCE_PASSWORD} # The value will be substituted + admin_password: ${ICECAST_ADMIN_PASSWORD} # The value will be substituted +``` + +::: + ## Setup LibreTime Once the files are downloaded, generate a set of random passwords for the different docker services used by LibreTime: @@ -48,9 +73,26 @@ RABBITMQ_DEFAULT_PASS=$(openssl rand -hex 16) ICECAST_SOURCE_PASSWORD=$(openssl rand -hex 16) ICECAST_ADMIN_PASSWORD=$(openssl rand -hex 16) ICECAST_RELAY_PASSWORD=$(openssl rand -hex 16)" >> .env -cat .env ``` +Generate a [configuration file](../configuration.md) from the `./config.template.yml` template with the previously generated passwords: + +```bash +bash -a -c "source .env; envsubst < config.template.yml > config.yml" +``` + +:::note + +On Debian based systems, if the `envsubst` command isn't found you can install it with: + +```bash +sudo apt install gettext-base +``` + +::: + +Next, edit the [configuration file](../configuration.md) at `./config.yml` to fill required information and to match your needs. + :::info You can find more details in the `docker-compose.yml` file or on the external services docker specific documentation: @@ -61,29 +103,6 @@ You can find more details in the `docker-compose.yml` file or on the external se ::: -Next, edit the [configuration file](../configuration.md) at `./config.yml` to set the previously generated passwords, fill required information, and to match your needs. - -:::info - -The `docker/config.yml` configuration file you previously downloaded already contains specific values required by the container setup, you shouldn't change them: - -```yaml -database: - host: "postgres" -rabbitmq: - host: "rabbitmq" -playout: - liquidsoap_host: "liquidsoap" -liquidsoap: - server_listen_address: "0.0.0.0" -stream: - outputs: - .default_icecast_output: - host: "icecast" -``` - -::: - Next, run the following commands to setup the database: ```bash diff --git a/tools/update-config-files.sh b/tools/update-config-files.sh index 724f19144..ed5726456 100755 --- a/tools/update-config-files.sh +++ b/tools/update-config-files.sh @@ -37,11 +37,24 @@ set_docker_config() { set_config "icecast" stream outputs .default_icecast_output host } +set_docker_config_template_vars() { + set_config "\${POSTGRES_PASSWORD}" database password + set_config "\${RABBITMQ_DEFAULT_PASS}" rabbitmq password + set_config "\${ICECAST_SOURCE_PASSWORD}" stream outputs .default_icecast_output source_password + set_config "\${ICECAST_ADMIN_PASSWORD}" stream outputs .default_icecast_output admin_password +} + CONFIG_FILEPATH="docker/config.yml" cp "$CONFIG_ORIG_FILEPATH" "$CONFIG_FILEPATH" set_docker_config +CONFIG_FILEPATH="docker/config.template.yml" +cp "$CONFIG_ORIG_FILEPATH" "$CONFIG_FILEPATH" + +set_docker_config +set_docker_config_template_vars + CONFIG_FILEPATH="docker/example/config.yml" cp "$CONFIG_ORIG_FILEPATH" "$CONFIG_FILEPATH"