chore(docker): Fix PUID:PGID usage in entrypoint.sh

The non-root user and group were still being created in the Dockerfile,
which means that if the PUID or PGID were modified, those changes would
not be processed.

This change completely removes the `adduser` / `addgroup` commands and
instead the user spec is passed directly to `su-exec`.
pull/92/head
Robert Dailey 2 years ago
parent fba29e56d0
commit 347028ed3a

@ -29,13 +29,9 @@ ENV RECYCLARR_APP_DATA=/config \
VOLUME /config VOLUME /config
RUN set -ex; \ RUN apk add --no-cache busybox-suid su-exec libstdc++ tzdata;
cat /etc/passwd; \
apk add --no-cache busybox-suid su-exec libstdc++ tzdata; \ COPY --chmod=755 --from=build /build/recyclarr /usr/local/bin
addgroup --gid $PGID recyclarr; \ COPY --chmod=755 ./scripts/prod/*.sh /
adduser --uid $PUID --ingroup recyclarr --disabled-password --no-create-home recyclarr;
COPY --chown=recyclarr:recyclarr --chmod=544 --from=build /build/recyclarr /usr/local/bin
COPY --chown=recyclarr:recyclarr --chmod=544 ./scripts/prod/*.sh /
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

@ -8,7 +8,6 @@ networks:
services: services:
recyclarr: recyclarr:
image: ghcr.io/recyclarr/recyclarr image: ghcr.io/recyclarr/recyclarr
container_name: recyclarr
build: build:
context: . context: .
args: args:

@ -1,8 +1,12 @@
#!/bin/sh #!/bin/sh
set -e set -e
userspec="$PUID:$PGID"
chown "$userspec" "$RECYCLARR_APP_DATA"
if [ ! -f "$RECYCLARR_APP_DATA/recyclarr.yml" ]; then if [ ! -f "$RECYCLARR_APP_DATA/recyclarr.yml" ]; then
su-exec recyclarr recyclarr create-config su-exec "$userspec" recyclarr create-config
fi fi
# If the script has any arguments, invoke the CLI instead. This allows the image to be used as a CLI # If the script has any arguments, invoke the CLI instead. This allows the image to be used as a CLI
@ -13,12 +17,12 @@ fi
# ``` # ```
# #
if [ "$#" -gt 0 ]; then if [ "$#" -gt 0 ]; then
su-exec recyclarr recyclarr "$@" su-exec "$userspec" recyclarr "$@"
else else
echo "Creating crontab file..." echo "Creating crontab file..."
echo "$CRON_SCHEDULE /cron.sh" | crontab -u recyclarr - echo "$CRON_SCHEDULE su-exec \"$userspec\" /cron.sh" | crontab -
crontab -l -u recyclarr crontab -l
echo "Starting cron daemon..." echo "Starting cron daemon..."
exec crond -f exec crond -f

Loading…
Cancel
Save