Skip to content

Commit

Permalink
feature: support run as uid and pid
Browse files Browse the repository at this point in the history
  • Loading branch information
littleneko committed Sep 11, 2024
1 parent 3b7d0bb commit 593ea38
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ WORKDIR /bing
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY src/ .
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh

CMD [ "python3", "app.py", "--service-mode"]
RUN apt-get update && apt-get install -y \
gosu \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/bing/entrypoint.sh", "python3", "app.py", "--service-mode"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ All args can be read from environment variables, the environment variables with

## Docker Usage

Run as service and periodically scan new wallpaper:
Run as service and periodically scan new wallpaper.


Note that bing-dl runs as UID 1000 and GID 1000 by default. These may be altered with the `PUID` and `PGID` environment variables.

```shell
docker run -d \
-e BING_SCAN_INTERVAL=3600 \
-e [email protected] \
-e [email protected] \
-e BING_NOTIFY_USER_PASS=password \
-e PUID=1000 \
-e PGID=1000 \
-v /path/to/storage/folder:/bing/storage \
-v /path/to/download/folder:/bing/download \
littleneko/bing-dl:latest
Expand Down
16 changes: 16 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/sh

set -eu

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

if ! getent group "$PGID" >/dev/null; then
groupadd -g "$PGID" bing
fi

if ! getent passwd "$PUID" >/dev/null; then
useradd -u "$PUID" -g "$PGID" -m bing
fi

exec gosu "$PUID":"$PGID" "$@"

0 comments on commit 593ea38

Please sign in to comment.