diff --git a/Containerfile b/Containerfile index df80669..9155a83 100644 --- a/Containerfile +++ b/Containerfile @@ -2,6 +2,7 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} AS download ARG APP_VERSION +ARG PACKAGE_VERSION ARG TARGETARCH RUN --mount=type=secret,id=github_token \ @@ -30,7 +31,7 @@ RUN --mount=type=secret,id=github_token \ mkdir /sonarr; \ tar -xzf /tmp/sonarr.tar.gz -C /sonarr --strip-components=1; \ rm -rf /sonarr/Sonarr.Update; \ - printf 'UpdateMethod=docker\nBranch=%s\nPackageAuthor=[Tuxcrate](https://tuxcrate.com)\n' "$branch" > /package_info + printf 'UpdateMethod=docker\nBranch=%s\nPackageVersion=%s\nPackageAuthor=[Tuxcrate](https://tuxcrate.com)\n' "$branch" "${PACKAGE_VERSION:-${APP_VERSION}-local}" > /package_info FROM ${BASE_IMAGE} @@ -46,11 +47,12 @@ RUN set -eux; \ mkdir -p /config /data; \ chown 1000:1000 /config /data -COPY --from=download /sonarr /opt/sonarr -COPY --from=download /package_info /opt/package_info +# Sonarr only reads ../package_info when its application directory is named bin. +COPY --from=download /sonarr /opt/sonarr/bin +COPY --from=download /package_info /opt/sonarr/package_info USER 1000:1000 WORKDIR /config EXPOSE 8989 -ENTRYPOINT ["/opt/sonarr/Sonarr", "-nobrowser", "-data=/config"] +ENTRYPOINT ["/opt/sonarr/bin/Sonarr", "-nobrowser", "-data=/config"] diff --git a/tests/smoke.sh b/tests/smoke.sh index d52fdf8..dcfa037 100644 --- a/tests/smoke.sh +++ b/tests/smoke.sh @@ -4,6 +4,7 @@ set -euo pipefail image=${1:?A locally loaded image is required} version=${2:?The expected application version is required} platform=${3:?The image platform is required} +package_version=${PACKAGE_VERSION:-${version}-local} container= phase='starting the container with its default entrypoint and user' cleanup() { @@ -32,7 +33,7 @@ docker exec "$container" sh -eu -c ' test ! -w /opt/sonarr test -w /config test ! -e /usr/local/bin/sonarr-smoke-test - /opt/sonarr/ffprobe -version + /opt/sonarr/bin/ffprobe -version ' phase='waiting for nonempty sonarr.db and config.xml and an OK /ping response' @@ -63,6 +64,15 @@ if [[ $installed_version != "$version" ]]; then printf 'Expected Sonarr %s, got %s.\n' "$version" "$installed_version" >&2 exit 1 fi +phase='checking package version and the Tuxcrate author link in the status API' +system_status=$(docker exec "$container" sh -eu -c ' + api_key=$(sed -n "s:.*\(.*\).*:\1:p" /config/config.xml) + test -n "$api_key" + wget -T 5 -q -O - --header "X-Api-Key: $api_key" http://127.0.0.1:8989/api/v3/system/status +') +grep -Eq '"packageVersion"[[:space:]]*:[[:space:]]*"'"${package_version//./\\.}"'"' <<< "$system_status" +grep -Eq '"packageAuthor"[[:space:]]*:[[:space:]]*"\[Tuxcrate\]\(https://tuxcrate\.com\)"' <<< "$system_status" + phase='checking graceful shutdown' docker stop --time 30 "$container" > /dev/null exit_code=$(docker wait "$container")