Skip to content

Commit

Permalink
Added PUID and PGID environmental variables
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWicklowWolf authored Nov 13, 2024
1 parent 716f4a2 commit 9570894
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ FROM python:3.12-alpine
ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION}

# Create User
ARG UID=1000
ARG GID=1000
RUN addgroup -g $GID general_user && \
adduser -D -u $UID -G general_user -s /bin/sh general_user
# Install su-exec
RUN apk update && apk add --no-cache su-exec

# Create directories and set permissions
COPY . /radarec
WORKDIR /radarec
RUN chown -R $UID:$GID /radarec

# Install requirements and run code as general_user
# Install requirements
RUN pip install --no-cache-dir -r requirements.txt

# Make the script executable
RUN chmod +x thewicklowwolf-init.sh

# Expose port
EXPOSE 5000
USER general_user
CMD ["gunicorn", "src.RadaRec:app", "-c", "gunicorn_config.py"]

# Start the app
ENTRYPOINT ["./thewicklowwolf-init.sh"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
Certain values can be set via environment variables:
* __PUID__: The user ID to run the app with. Defaults to `1000`.
* __PGID__: The group ID to run the app with. Defaults to `1000`.
* __radarr_address__: The URL for Radarr. Defaults to `http://192.168.1.2:8686`.
* __radarr_api_key__: The API key for Radarr. Defaults to ``.
* __root_folder_path__: The root folder path for Movies. Defaults to `/data/media/movies/`.
Expand Down
47 changes: 47 additions & 0 deletions thewicklowwolf-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

echo -e "\033[1;32mTheWicklowWolf\033[0m"
echo -e "\033[1;34mRadaRec\033[0m"
echo "Initializing app..."

cat << 'EOF'
_____________________________________
.-'''''-.
.' `.
: :
: :
: _/| :
: =/_/ :
`._/ | .'
( / ,|...-'
\_/^\/||__
_/~ `""~`"` \_
__/ -'/ `-._ `\_\__
/ /-'` `\ \ \-.\
_____________________________________
Brought to you by TheWicklowWolf
_____________________________________
If you'd like to buy me a coffee:
https://buymeacoffee.com/thewicklow
EOF

PUID=${PUID:-1000}
PGID=${PGID:-1000}

echo "-----------------"
echo -e "\033[1mRunning with:\033[0m"
echo "PUID=${PUID}"
echo "PGID=${PGID}"
echo "-----------------"

# Create the required directories with the correct permissions
echo "Setting up directories.."
mkdir -p /radarec/config
chown -R ${PUID}:${PGID} /radarec

# Start the application with the specified user permissions
echo "Running RadaRec..."
exec su-exec ${PUID}:${PGID} gunicorn src.RadaRec:app -c gunicorn_config.py

0 comments on commit 9570894

Please sign in to comment.