From 81b2202ec31712f7d8dfd5d5819803d2cbecb7ef Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 7 Jun 2024 07:32:38 -0400 Subject: [PATCH] feat(readarr)!: official env support added Signed-off-by: Devin Buhl --- apps/readarr/Dockerfile | 25 +++--------------- apps/readarr/README.md | 24 ------------------ apps/readarr/ci/goss.yaml | 3 --- apps/readarr/config.xml.tmpl | 26 ------------------- apps/readarr/entrypoint.sh | 49 ------------------------------------ 5 files changed, 4 insertions(+), 123 deletions(-) delete mode 100644 apps/readarr/README.md delete mode 100644 apps/readarr/config.xml.tmpl diff --git a/apps/readarr/Dockerfile b/apps/readarr/Dockerfile index e86649d8..77820b36 100644 --- a/apps/readarr/Dockerfile +++ b/apps/readarr/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 @@ -18,10 +6,8 @@ ARG VERSION ARG CHANNEL ENV \ - READARR__INSTANCE_NAME="Readarr" \ - READARR__BRANCH="${CHANNEL}" \ - READARR__PORT="8787" \ - READARR__ANALYTICS_ENABLED="False" + COMPlus_EnableDiagnostics="0" \ + READARR__UPDATE__BRANCH="${CHANNEL}" ENV UMASK="0002" \ TZ="Etc/UTC" @@ -42,7 +28,6 @@ RUN \ nano \ sqlite-libs \ tzdata \ - xmlstarlet \ && \ case "${TARGETPLATFORM}" in \ 'linux/amd64') export ARCH='x64' ;; \ @@ -51,19 +36,17 @@ RUN \ && \ mkdir -p /app/bin \ && \ - curl -fsSL "https://readarr.servarr.com/v1/update/${READARR__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ + curl -fsSL "https://readarr.servarr.com/v1/update/${READARR__UPDATE__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ | tar xzf - -C /app/bin --strip-components=1 \ && \ rm -rf /app/bin/Readarr.Update \ && \ - printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${READARR__BRANCH}" "${VERSION}" > /app/package_info \ + printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${READARR__UPDATE__BRANCH}" "${VERSION}" > /app/package_info \ && chown -R root:root /app \ && chmod -R 755 /app \ && rm -rf /tmp/* -COPY ./apps/readarr/config.xml.tmpl /app/config.xml.tmpl COPY ./apps/readarr/entrypoint.sh /entrypoint.sh -COPY --from=envsubst /go/bin/envsubst /usr/local/bin/envsubst USER nobody:nogroup WORKDIR /config diff --git a/apps/readarr/README.md b/apps/readarr/README.md deleted file mode 100644 index 225fea80..00000000 --- a/apps/readarr/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# readarr - -## Custom environment configuration - -This container support setting certain custom enviroment variables with the use of [drone/envsubst](https://github.com/drone/envsubst). - -| Name | Default | -|----------------------------------|---------------------| -| READARR__ANALYTICS_ENABLED | `False` | -| READARR__API_KEY | | -| READARR__AUTHENTICATION_METHOD | `None` | -| READARR__AUTHENTICATION_REQUIRED | | -| READARR__BRANCH | _(current channel)_ | -| READARR__INSTANCE_NAME | `Readarr` | -| READARR__LOG_LEVEL | `info` | -| READARR__PORT | `8787` | -| READARR__POSTGRES_HOST | | -| READARR__POSTGRES_MAIN_DB | | -| READARR__POSTGRES_LOG_DB | | -| READARR__POSTGRES_CACHE_DB | | -| READARR__POSTGRES_PASSWORD | | -| READARR__POSTGRES_PORT | `5432` | -| READARR__POSTGRES_USER | | -| READARR__URL_BASE | | diff --git a/apps/readarr/ci/goss.yaml b/apps/readarr/ci/goss.yaml index 922bb506..03c54998 100644 --- a/apps/readarr/ci/goss.yaml +++ b/apps/readarr/ci/goss.yaml @@ -10,6 +10,3 @@ http: http://localhost:8787: status: 200 timeout: 5000 -file: - /usr/local/bin/envsubst: - exists: true diff --git a/apps/readarr/config.xml.tmpl b/apps/readarr/config.xml.tmpl deleted file mode 100644 index 544fe5cb..00000000 --- a/apps/readarr/config.xml.tmpl +++ /dev/null @@ -1,26 +0,0 @@ - - ${READARR__LOG_LEVEL:-info} - ${READARR__URL_BASE} - ${READARR__BRANCH} - ${READARR__API_KEY} - ${READARR__AUTHENTICATION_METHOD:-None} - ${READARR__AUTHENTICATION_REQUIRED} - ${READARR__INSTANCE_NAME} - ${READARR__POSTGRES_USER} - ${READARR__POSTGRES_PASSWORD} - ${READARR__POSTGRES_PORT:-5432} - ${READARR__POSTGRES_HOST} - ${READARR__POSTGRES_MAIN_DB} - ${READARR__POSTGRES_LOG_DB} - ${READARR__POSTGRES_CACHE_DB} - ${READARR__PORT} - * - False - False - 6969 - - - BuiltIn - ${READARR__ANALYTICS_ENABLED} - ${READARR__THEME:-auto} - diff --git a/apps/readarr/entrypoint.sh b/apps/readarr/entrypoint.sh index 39bdb16f..ccd0cdb7 100755 --- a/apps/readarr/entrypoint.sh +++ b/apps/readarr/entrypoint.sh @@ -1,54 +1,5 @@ #!/usr/bin/env bash -# Discover existing configuration settings for backwards compatibility -if [[ -f /config/config.xml ]]; then - current_log_level="$(xmlstarlet sel -t -v "//LogLevel" -nl /config/config.xml)" - current_url_base="$(xmlstarlet sel -t -v "//UrlBase" -nl /config/config.xml)" - current_branch="$(xmlstarlet sel -t -v "//Branch" -nl /config/config.xml)" - 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_instance_name="$(xmlstarlet sel -t -v "//InstanceName" -nl /config/config.xml)" - current_postgres_user="$(xmlstarlet sel -t -v "//PostgresUser" -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_host="$(xmlstarlet sel -t -v "//PostgresHost" -nl /config/config.xml)" - current_postgres_main_db="$(xmlstarlet sel -t -v "//PostgresMainDb" -nl /config/config.xml)" - current_postgres_log_db="$(xmlstarlet sel -t -v "//PostgresLogDb" -nl /config/config.xml)" - current_postgres_cache_db="$(xmlstarlet sel -t -v "//PostgresCacheDb" -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 READARR__ variables set -[[ -z "${READARR__LOG_LEVEL}" && -n "${current_log_level}" ]] && xmlstarlet edit --inplace --update //LogLevel -v "${current_log_level}" /config/config.xml -[[ -z "${READARR__URL_BASE}" && -n "${current_url_base}" ]] && xmlstarlet edit --inplace --update //UrlBase -v "${current_url_base}" /config/config.xml -[[ -z "${READARR__BRANCH}" && -n "${current_branch}" ]] && xmlstarlet edit --inplace --update //Branch -v "${current_branch}" /config/config.xml -[[ -z "${READARR__ANALYTICS_ENABLED}" && -n "${current_analytics_enabled}" ]] && xmlstarlet edit --inplace --update //AnalyticsEnabled -v "${current_analytics_enabled}" /config/config.xml -[[ -z "${READARR__API_KEY}" && -n "${current_api_key}" ]] && xmlstarlet edit --inplace --update //ApiKey -v "${current_api_key}" /config/config.xml -[[ -z "${READARR__AUTHENTICATION_METHOD}" && -n "${current_authentication_method}" ]] && xmlstarlet edit --inplace --update //AuthenticationMethod -v "${current_authentication_method}" /config/config.xml -[[ -z "${READARR__AUTHENTICATION_REQUIRED}" && -n "${current_authentication_required}" ]] && xmlstarlet edit --inplace --update //AuthenticationRequired -v "${current_authentication_required}" /config/config.xml -[[ -z "${READARR__INSTANCE_NAME}" && -n "${current_instance_name}" ]] && xmlstarlet edit --inplace --update //InstanceName -v "${current_instance_name}" /config/config.xml -[[ -z "${READARR__POSTGRES_USER}" && -n "${current_postgres_user}" ]] && xmlstarlet edit --inplace --update //PostgresUser -v "${current_postgres_user}" /config/config.xml -[[ -z "${READARR__POSTGRES_PASSWORD}" && -n "${current_postgres_password}" ]] && xmlstarlet edit --inplace --update //PostgresPassword -v "${current_postgres_password}" /config/config.xml -[[ -z "${READARR__POSTGRES_PORT}" && -n "${current_postgres_port}" ]] && xmlstarlet edit --inplace --update //PostgresPort -v "${current_postgres_port}" /config/config.xml -[[ -z "${READARR__POSTGRES_HOST}" && -n "${current_postgres_host}" ]] && xmlstarlet edit --inplace --update //PostgresHost -v "${current_postgres_host}" /config/config.xml -[[ -z "${READARR__POSTGRES_MAIN_DB}" && -n "${current_postgres_main_db}" ]] && xmlstarlet edit --inplace --update //PostgresMainDb -v "${current_postgres_main_db}" /config/config.xml -[[ -z "${READARR__POSTGRES_LOG_DB}" && -n "${current_postgres_log_db}" ]] && xmlstarlet edit --inplace --update //PostgresLogDb -v "${current_postgres_log_db}" /config/config.xml -[[ -z "${READARR__POSTGRES_CACHE_DB}" && -n "${current_postgres_cache_db}" ]] && xmlstarlet edit --inplace --update //PostgresCacheDb -v "${current_postgres_cache_db}" /config/config.xml -[[ -z "${READARR__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 [[ "${READARR__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/Readarr \