From fb003cd15743085b2b241df67be7859a9515b61e Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Thu, 6 Jun 2024 19:10:20 -0400 Subject: [PATCH] feat(prowlarr)!: official env support added (#1049) --- apps/prowlarr/Dockerfile | 24 +++--------------- apps/prowlarr/README.md | 23 ----------------- apps/prowlarr/ci/goss.yaml | 3 --- apps/prowlarr/config.xml.tmpl | 25 ------------------- apps/prowlarr/entrypoint.sh | 47 ----------------------------------- 5 files changed, 3 insertions(+), 119 deletions(-) delete mode 100644 apps/prowlarr/README.md delete mode 100644 apps/prowlarr/config.xml.tmpl diff --git a/apps/prowlarr/Dockerfile b/apps/prowlarr/Dockerfile index db2db2ddb..5a87ac0d4 100644 --- a/apps/prowlarr/Dockerfile +++ b/apps/prowlarr/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" \ - PROWLARR__INSTANCE_NAME="Prowlarr" \ - PROWLARR__BRANCH="${CHANNEL}" \ - PROWLARR__PORT="9696" \ - PROWLARR__ANALYTICS_ENABLED="False" + PROWLARR__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://prowlarr.servarr.com/v1/update/${PROWLARR__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ + curl -fsSL "https://prowlarr.servarr.com/v1/update/${PROWLARR__UPDATE__BRANCH}/updatefile?version=${VERSION}&os=linuxmusl&runtime=netcore&arch=${ARCH}" \ | tar xzf - -C /app/bin --strip-components=1 \ && \ rm -rf /app/bin/Prowlarr.Update \ && \ - printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${PROWLARR__BRANCH}" "${VERSION}" > /app/package_info \ + printf "UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[onedr0p](https://github.com/onedr0p)\n" "${PROWLARR__UPDATE__BRANCH}" "${VERSION}" > /app/package_info \ && chown -R root:root /app \ && chmod -R 755 /app \ && rm -rf /tmp/* -COPY ./apps/prowlarr/config.xml.tmpl /app/config.xml.tmpl COPY ./apps/prowlarr/entrypoint.sh /entrypoint.sh -COPY --from=envsubst /go/bin/envsubst /usr/local/bin/envsubst USER nobody:nogroup WORKDIR /config diff --git a/apps/prowlarr/README.md b/apps/prowlarr/README.md deleted file mode 100644 index 71eacbf72..000000000 --- a/apps/prowlarr/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# prowlarr - -## Custom environment configuration - -This container support setting certain custom enviroment variables with the use of [drone/envsubst](https://github.com/drone/envsubst). - -| Name | Default | -|-----------------------------------|---------------------| -| PROWLARR__ANALYTICS_ENABLED | `False` | -| PROWLARR__API_KEY | | -| PROWLARR__AUTHENTICATION_METHOD | `None` | -| PROWLARR__AUTHENTICATION_REQUIRED | | -| PROWLARR__BRANCH | _(current channel)_ | -| PROWLARR__INSTANCE_NAME | `Prowlarr` | -| PROWLARR__LOG_LEVEL | `info` | -| PROWLARR__PORT | `9696` | -| PROWLARR__POSTGRES_HOST | | -| PROWLARR__POSTGRES_MAIN_DB | | -| PROWLARR__POSTGRES_LOG_DB | | -| PROWLARR__POSTGRES_PASSWORD | | -| PROWLARR__POSTGRES_PORT | `5432` | -| PROWLARR__POSTGRES_USER | | -| PROWLARR__URL_BASE | | diff --git a/apps/prowlarr/ci/goss.yaml b/apps/prowlarr/ci/goss.yaml index bd4bef2d0..7867d50db 100644 --- a/apps/prowlarr/ci/goss.yaml +++ b/apps/prowlarr/ci/goss.yaml @@ -10,6 +10,3 @@ http: http://localhost:9696: status: 200 timeout: 5000 -file: - /usr/local/bin/envsubst: - exists: true diff --git a/apps/prowlarr/config.xml.tmpl b/apps/prowlarr/config.xml.tmpl deleted file mode 100644 index aac35be46..000000000 --- a/apps/prowlarr/config.xml.tmpl +++ /dev/null @@ -1,25 +0,0 @@ - - ${PROWLARR__LOG_LEVEL:-info} - ${PROWLARR__URL_BASE} - ${PROWLARR__BRANCH} - ${PROWLARR__API_KEY} - ${PROWLARR__AUTHENTICATION_METHOD:-External} - ${PROWLARR__AUTHENTICATION_REQUIRED:-0} - ${PROWLARR__INSTANCE_NAME} - ${PROWLARR__POSTGRES_USER} - ${PROWLARR__POSTGRES_PASSWORD} - ${PROWLARR__POSTGRES_PORT:-5432} - ${PROWLARR__POSTGRES_HOST} - ${PROWLARR__POSTGRES_MAIN_DB} - ${PROWLARR__POSTGRES_LOG_DB} - ${PROWLARR__PORT} - * - False - False - 6969 - - - BuiltIn - ${PROWLARR__ANALYTICS_ENABLED} - ${PROWLARR__THEME:-auto} - diff --git a/apps/prowlarr/entrypoint.sh b/apps/prowlarr/entrypoint.sh index a6ecf4ba9..14423d51c 100755 --- a/apps/prowlarr/entrypoint.sh +++ b/apps/prowlarr/entrypoint.sh @@ -1,52 +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_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 PROWLARR__ variables set -[[ -z "${PROWLARR__LOG_LEVEL}" && -n "${current_log_level}" ]] && xmlstarlet edit --inplace --update //LogLevel -v "${current_log_level}" /config/config.xml -[[ -z "${PROWLARR__URL_BASE}" && -n "${current_url_base}" ]] && xmlstarlet edit --inplace --update //UrlBase -v "${current_url_base}" /config/config.xml -[[ -z "${PROWLARR__BRANCH}" && -n "${current_branch}" ]] && xmlstarlet edit --inplace --update //Branch -v "${current_branch}" /config/config.xml -[[ -z "${PROWLARR__ANALYTICS_ENABLED}" && -n "${current_analytics_enabled}" ]] && xmlstarlet edit --inplace --update //AnalyticsEnabled -v "${current_analytics_enabled}" /config/config.xml -[[ -z "${PROWLARR__API_KEY}" && -n "${current_api_key}" ]] && xmlstarlet edit --inplace --update //ApiKey -v "${current_api_key}" /config/config.xml -[[ -z "${PROWLARR__AUTHENTICATION_METHOD}" && -n "${current_authentication_method}" ]] && xmlstarlet edit --inplace --update //AuthenticationMethod -v "${current_authentication_method}" /config/config.xml -[[ -z "${PROWLARR__AUTHENTICATION_REQUIRED}" && -n "${current_authentication_required}" ]] && xmlstarlet edit --inplace --update //AuthenticationRequired -v "${current_authentication_required}" /config/config.xml -[[ -z "${PROWLARR__INSTANCE_NAME}" && -n "${current_instance_name}" ]] && xmlstarlet edit --inplace --update //InstanceName -v "${current_instance_name}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_USER}" && -n "${current_postgres_user}" ]] && xmlstarlet edit --inplace --update //PostgresUser -v "${current_postgres_user}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_PASSWORD}" && -n "${current_postgres_password}" ]] && xmlstarlet edit --inplace --update //PostgresPassword -v "${current_postgres_password}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_PORT}" && -n "${current_postgres_port}" ]] && xmlstarlet edit --inplace --update //PostgresPort -v "${current_postgres_port}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_HOST}" && -n "${current_postgres_host}" ]] && xmlstarlet edit --inplace --update //PostgresHost -v "${current_postgres_host}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_MAIN_DB}" && -n "${current_postgres_main_db}" ]] && xmlstarlet edit --inplace --update //PostgresMainDb -v "${current_postgres_main_db}" /config/config.xml -[[ -z "${PROWLARR__POSTGRES_LOG_DB}" && -n "${current_postgres_log_db}" ]] && xmlstarlet edit --inplace --update //PostgresLogDb -v "${current_postgres_log_db}" /config/config.xml -[[ -z "${PROWLARR__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 [[ "${PROWLARR__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/Prowlarr \