Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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}

Expand All @@ -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"]
12 changes: 11 additions & 1 deletion tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:.*<ApiKey>\(.*\)</ApiKey>.*:\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")
Expand Down