Skip to content

Commit

Permalink
feat(prowlarr)!: official env support added (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p committed Jun 6, 2024
1 parent 2860c84 commit fb003cd
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 119 deletions.
24 changes: 3 additions & 21 deletions apps/prowlarr/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -43,7 +28,6 @@ RUN \
nano \
sqlite-libs \
tzdata \
xmlstarlet \
&& \
case "${TARGETPLATFORM}" in \
'linux/amd64') export ARCH='x64' ;; \
Expand All @@ -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
Expand Down
23 changes: 0 additions & 23 deletions apps/prowlarr/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions apps/prowlarr/ci/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ http:
http://localhost:9696:
status: 200
timeout: 5000
file:
/usr/local/bin/envsubst:
exists: true
25 changes: 0 additions & 25 deletions apps/prowlarr/config.xml.tmpl

This file was deleted.

47 changes: 0 additions & 47 deletions apps/prowlarr/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down

0 comments on commit fb003cd

Please sign in to comment.