From 233778a5784e2396c726002664edab94203d26c9 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Thu, 6 Jun 2024 18:59:53 -0400 Subject: [PATCH] feat(radarr)!: official env support added (#1047) --- apps/radarr/Dockerfile | 24 +++---------------- apps/radarr/README.md | 23 ------------------ apps/radarr/ci/goss.yaml | 3 --- apps/radarr/config.xml.tmpl | 25 -------------------- apps/radarr/entrypoint.sh | 47 ------------------------------------- 5 files changed, 3 insertions(+), 119 deletions(-) delete mode 100644 apps/radarr/README.md delete mode 100644 apps/radarr/config.xml.tmpl diff --git a/apps/radarr/Dockerfile b/apps/radarr/Dockerfile index 5a070f50..45a534ad 100644 --- a/apps/radarr/Dockerfile +++ b/apps/radarr/Dockerfile @@ -1,16 +1,4 @@ ARG VERSION -FROM docker.io/library/golang:1.22-alpine as envsubst -ARG VERSION -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT="" -ARG TARGETPLATFORM -ENV CGO_ENABLED=0 \ - GOOS=${TARGETOS} \ - GOARCH=${TARGETARCH} \ - GOARM=${TARGETVARIANT} -RUN go install -ldflags="-s -w" github.com/drone/envsubst/cmd/envsubst@latest - FROM docker.io/library/alpine:3.20 ARG TARGETPLATFORM @@ -19,10 +7,7 @@ ARG CHANNEL ENV \ COMPlus_EnableDiagnostics="0" \ - RADARR__INSTANCE_NAME="Radarr" \ - RADARR__BRANCH="${CHANNEL}" \ - RADARR__PORT="7878" \ - RADARR__ANALYTICS_ENABLED="False" + RADARR__UPDATE__BRANCH="${CHANNEL}" ENV UMASK="0002" \ TZ="Etc/UTC" @@ -43,7 +28,6 @@ RUN \ nano \ sqlite-libs \ tzdata \ - xmlstarlet \ && \ case "${TARGETPLATFORM}" in \ 'linux/amd64') export ARCH='x64' ;; \ @@ -52,19 +36,17 @@ RUN \ && \ mkdir -p /app/bin \ && \ - curl -fsSL "https://radarr.servarr.com/v1/update/${RADARR__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ + curl -fsSL "https://radarr.servarr.com/v1/update/${RADARR__UPDATE__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ | tar xzf - -C /app/bin --strip-components=1 \ && \ rm -rf /app/bin/Radarr.Update \ && \ - printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${RADARR__BRANCH}" "${VERSION}" > /app/package_info \ + printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${RADARR__UPDATE__BRANCH}" "${VERSION}" > /app/package_info \ && chown -R root:root /app \ && chmod -R 755 /app \ && rm -rf /tmp/* -COPY ./apps/radarr/config.xml.tmpl /app/config.xml.tmpl COPY ./apps/radarr/entrypoint.sh /entrypoint.sh -COPY --from=envsubst /go/bin/envsubst /usr/local/bin/envsubst USER nobody:nogroup WORKDIR /config diff --git a/apps/radarr/README.md b/apps/radarr/README.md deleted file mode 100644 index aea7dd8c..00000000 --- a/apps/radarr/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# radarr - -## Custom environment configuration - -This container support setting certain custom enviroment variables with the use of [drone/envsubst](https://github.com/drone/envsubst). - -| Name | Default | -|---------------------------------|---------------------| -| RADARR__ANALYTICS_ENABLED | `False` | -| RADARR__API_KEY | | -| RADARR__AUTHENTICATION_METHOD | `None` | -| RADARR__AUTHENTICATION_REQUIRED | | -| RADARR__BRANCH | _(current channel)_ | -| RADARR__INSTANCE_NAME | `Radarr` | -| RADARR__LOG_LEVEL | `info` | -| RADARR__PORT | `7878` | -| RADARR__POSTGRES_HOST | | -| RADARR__POSTGRES_MAIN_DB | | -| RADARR__POSTGRES_LOG_DB | | -| RADARR__POSTGRES_PASSWORD | | -| RADARR__POSTGRES_PORT | `5432` | -| RADARR__POSTGRES_USER | | -| RADARR__URL_BASE | | diff --git a/apps/radarr/ci/goss.yaml b/apps/radarr/ci/goss.yaml index 91bb73a2..0c9d8c5d 100644 --- a/apps/radarr/ci/goss.yaml +++ b/apps/radarr/ci/goss.yaml @@ -10,6 +10,3 @@ http: http://localhost:7878: status: 200 timeout: 5000 -file: - /usr/local/bin/envsubst: - exists: true diff --git a/apps/radarr/config.xml.tmpl b/apps/radarr/config.xml.tmpl deleted file mode 100644 index a1c0e2ea..00000000 --- a/apps/radarr/config.xml.tmpl +++ /dev/null @@ -1,25 +0,0 @@ - - ${RADARR__LOG_LEVEL:-info} - ${RADARR__URL_BASE} - ${RADARR__BRANCH} - ${RADARR__API_KEY} - ${RADARR__AUTHENTICATION_METHOD:-External} - ${RADARR__AUTHENTICATION_REQUIRED:-DisabledForLocalAddresses} - ${RADARR__INSTANCE_NAME} - ${RADARR__POSTGRES_USER} - ${RADARR__POSTGRES_PASSWORD} - ${RADARR__POSTGRES_PORT:-5432} - ${RADARR__POSTGRES_HOST} - ${RADARR__POSTGRES_MAIN_DB} - ${RADARR__POSTGRES_LOG_DB} - ${RADARR__PORT} - * - False - False - 6969 - - - BuiltIn - ${RADARR__ANALYTICS_ENABLED} - ${RADARR__THEME:-auto} - diff --git a/apps/radarr/entrypoint.sh b/apps/radarr/entrypoint.sh index 049b91bb..154785bc 100755 --- a/apps/radarr/entrypoint.sh +++ b/apps/radarr/entrypoint.sh @@ -1,52 +1,5 @@ #!/usr/bin/env bash -# Discover existing configuration settings for backwards compatibility -if [[ -f /config/config.xml ]]; then - current_analytics_enabled="$(xmlstarlet sel -t -v "//AnalyticsEnabled" -nl /config/config.xml)" - current_api_key="$(xmlstarlet sel -t -v "//ApiKey" -nl /config/config.xml)" - current_authentication_method="$(xmlstarlet sel -t -v "//AuthenticationMethod" -nl /config/config.xml)" - current_authentication_required="$(xmlstarlet sel -t -v "//AuthenticationRequired" -nl /config/config.xml)" - current_branch="$(xmlstarlet sel -t -v "//Branch" -nl /config/config.xml)" - current_instance_name="$(xmlstarlet sel -t -v "//InstanceName" -nl /config/config.xml)" - current_log_level="$(xmlstarlet sel -t -v "//LogLevel" -nl /config/config.xml)" - current_postgres_host="$(xmlstarlet sel -t -v "//PostgresHost" -nl /config/config.xml)" - current_postgres_log_db="$(xmlstarlet sel -t -v "//PostgresLogDb" -nl /config/config.xml)" - current_postgres_main_db="$(xmlstarlet sel -t -v "//PostgresMainDb" -nl /config/config.xml)" - current_postgres_password="$(xmlstarlet sel -t -v "//PostgresPassword" -nl /config/config.xml)" - current_postgres_port="$(xmlstarlet sel -t -v "//PostgresPort" -nl /config/config.xml)" - current_postgres_user="$(xmlstarlet sel -t -v "//PostgresUser" -nl /config/config.xml)" - current_url_base="$(xmlstarlet sel -t -v "//UrlBase" -nl /config/config.xml)" - current_theme="$(xmlstarlet sel -t -v "//Theme" -nl /config/config.xml)" -fi - -# Update config.xml with environment variables -envsubst < /app/config.xml.tmpl > /config/config.xml - -# Override configuation values from existing config.xml if there are no RADARR__ variables set -[[ -z "${RADARR__ANALYTICS_ENABLED}" && -n "${current_analytics_enabled}" ]] && xmlstarlet edit --inplace --update //AnalyticsEnabled -v "${current_analytics_enabled}" /config/config.xml -[[ -z "${RADARR__API_KEY}" && -n "${current_api_key}" ]] && xmlstarlet edit --inplace --update //ApiKey -v "${current_api_key}" /config/config.xml -[[ -z "${RADARR__AUTHENTICATION_METHOD}" && -n "${current_authentication_method}" ]] && xmlstarlet edit --inplace --update //AuthenticationMethod -v "${current_authentication_method}" /config/config.xml -[[ -z "${RADARR__AUTHENTICATION_REQUIRED}" && -n "${current_authentication_required}" ]] && xmlstarlet edit --inplace --update //AuthenticationRequired -v "${current_authentication_required}" /config/config.xml -[[ -z "${RADARR__BRANCH}" && -n "${current_branch}" ]] && xmlstarlet edit --inplace --update //Branch -v "${current_branch}" /config/config.xml -[[ -z "${RADARR__INSTANCE_NAME}" && -n "${current_instance_name}" ]] && xmlstarlet edit --inplace --update //InstanceName -v "${current_instance_name}" /config/config.xml -[[ -z "${RADARR__LOG_LEVEL}" && -n "${current_log_level}" ]] && xmlstarlet edit --inplace --update //LogLevel -v "${current_log_level}" /config/config.xml -[[ -z "${RADARR__POSTGRES_HOST}" && -n "${current_postgres_host}" ]] && xmlstarlet edit --inplace --update //PostgresHost -v "${current_postgres_host}" /config/config.xml -[[ -z "${RADARR__POSTGRES_LOG_DB}" && -n "${current_postgres_log_db}" ]] && xmlstarlet edit --inplace --update //PostgresLogDb -v "${current_postgres_log_db}" /config/config.xml -[[ -z "${RADARR__POSTGRES_MAIN_DB}" && -n "${current_postgres_main_db}" ]] && xmlstarlet edit --inplace --update //PostgresMainDb -v "${current_postgres_main_db}" /config/config.xml -[[ -z "${RADARR__POSTGRES_PASSWORD}" && -n "${current_postgres_password}" ]] && xmlstarlet edit --inplace --update //PostgresPassword -v "${current_postgres_password}" /config/config.xml -[[ -z "${RADARR__POSTGRES_PORT}" && -n "${current_postgres_port}" ]] && xmlstarlet edit --inplace --update //PostgresPort -v "${current_postgres_port}" /config/config.xml -[[ -z "${RADARR__POSTGRES_USER}" && -n "${current_postgres_user}" ]] && xmlstarlet edit --inplace --update //PostgresUser -v "${current_postgres_user}" /config/config.xml -[[ -z "${RADARR__URL_BASE}" && -n "${current_url_base}" ]] && xmlstarlet edit --inplace --update //UrlBase -v "${current_url_base}" /config/config.xml -[[ -z "${RADARR__THEME}" && -n "${current_theme}" ]] && xmlstarlet edit --inplace --update //Theme -v "${current_theme}" /config/config.xml - -# BindAddress, LaunchBrowser, Port, EnableSsl, SslPort, SslCertPath, SslCertPassword, UpdateMechanism -# have been omited because their configuration is not really needed in a container environment - -if [[ "${RADARR__LOG_LEVEL}" == "debug" || "${current_log_level}" == "debug" ]]; then - echo "Starting with the following configuration..." - xmlstarlet format --omit-decl /config/config.xml -fi - #shellcheck disable=SC2086 exec \ /app/bin/Radarr \