Skip to content

Commit

Permalink
feat: include default config file
Browse files Browse the repository at this point in the history
Copy 'gallery-dl.conf' into the Docker image and move it into the directory mounted at '/config' on container startup if no config file already exists in that location.
  • Loading branch information
qx6ghqkz committed Dec 14, 2024
1 parent 42e2191 commit 158b1e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ scripts/
*.cmd
*.ps1

# Config files
*.conf
*.json

# Images
images/

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'templates/**'
- '**.py'
- 'Dockerfile'
- 'gallery-dl.conf'
- 'requirements.txt'
- 'start.sh'
tags:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Configuration of gallery-dl is as documented in the [official documentation](htt

The configuration file must be mounted inside the Docker container in one of the locations where gallery-dl will check for the config file.

The server uses a custom target config location of `/config/gallery-dl.conf`. A [default configuration file](https://github.com/qx6ghqkz/gallery-dl-server/blob/main/gallery-dl.conf) for use with gallery-dl-server has been provided.
The server uses a custom target config location of `/config/gallery-dl.conf`. A [default configuration file](https://github.com/qx6ghqkz/gallery-dl-server/blob/main/gallery-dl.conf) for use with gallery-dl-server has been provided and will automatically be placed in the directory mounted to `/config` if the file does not already exist in that location.

For more information on configuration file options, see [gallery-dl/docs/configuration.rst](https://github.com/mikf/gallery-dl/blob/master/docs/configuration.rst).

Expand Down
5 changes: 3 additions & 2 deletions gallery-dl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ def download(url, request_options):
if output:
formatted_output = remove_ansi_escape_sequences(output.strip())

if formatted_output.startswith("#"):
if formatted_output.startswith("# "):
logger.warning(
"File already exists and/or its ID is in a download archive."
"File already exists and/or its ID is in a download archive: %s",
formatted_output.removeprefix("# "),
)
elif "error" in formatted_output.lower():
logger.error(formatted_output)
Expand Down
9 changes: 8 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod_ids () {
groupmod --non-unique --gid "$GID" appgroup >/dev/null 2>&1
usermod --non-unique --gid "$GID" --uid "$UID" appuser >/dev/null 2>&1

chown --quiet -R "$UID:$GID" /usr/src/app /.cache/pip /.local
chown -R "$UID:$GID" /usr/src/app /.cache/pip /.local >/dev/null 2>&1
}

init () {
Expand Down Expand Up @@ -54,6 +54,7 @@ log() {
}

start() {
get_conf
if [[ $1 -eq 0 ]]; then
exec su-exec appuser uvicorn gallery-dl-server:app --host 0.0.0.0 --port "$CONTAINER_PORT" --log-level info --no-access-log
elif [[ $1 -eq 1 ]]; then
Expand All @@ -63,6 +64,12 @@ start() {
fi
}

get_conf() {
if [[ -d /config ]]; then
mv -n /usr/src/app/gallery-dl.conf /config >/dev/null 2>&1
fi
}

exit() {
if [[ $1 -eq 0 ]]; then
echo "error: fatal error"
Expand Down

0 comments on commit 158b1e9

Please sign in to comment.